Ok I've spent more time than you would believe on this one. I built the program, started from scratch. Over the course of the last week I've spent no shit about 30 hours on this and still cant get it to work right.

What is suppose to happen is the user is suppose to enter a dollaramount, the program then proceeds to give them a readout of the fewest number of coins required for that amount (IE $1.42 converts to 1 dollar, 1 quarter, 1 dime, 1 nickel, and 2 pennies.)

My current code is as follows...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MoneyCalculator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public enum moneyvalues 
        {
            dollar = 100,
            quarter = 25,
            dime = 10,
            nickel = 5,
            penny = 1,
        }

        private void button1_click(object sender, EventArgs e)
        {
                string ida = textBox1.Text;
                decimal nda = (decimal.Parse(ida) * 100);

                if (moneyvalues.dollar >= nda)
                {
                    (nda = nda - moneyvalues.dollar);
                    dolcnt++; 
                } 

                else if (moneyvalues.quarter >= nda)
                { 
                    (nda = nda - moneyvalues.quarter);
                    qrtcnt++;
                }

                else if (moneyvalues.dime >= nda)
                { 
                    (nda = nda - moneyvalues.dime);
                    dmecnt++;
                }

                else if (moneyvalues.nickel >= nda)
                { 
                    (nda = nda - moneyvalues.nickel);
                    nklcnt++;
                }
                
                else if (moneyvalues.penny >= nda)
                { 
                    (nda = nda - moneyvalues.penny);
                    pnycnt++;
                }

                else
                    text = ("You have " + (string.dolcnt) + "dollar bill(s), " + (string.qrtcnt) + "quarter(s), " + (string.dmecnt) + "dime(s), " + (string.nklcnt) + "nickel(s), " + (string.pnycnt) + "pennies!");
                    textBox2 = text;
        }
            private void Form1_Load(object sender, EventArgs e)
            {

            }
                 
        }

    }  
}

As of right now I am getting a "Type or namespace definition or end-of-file expected build error. I've been through this a 100 times, and the brackets are all there, so I've got no clue as to what could be wrong. I cant even check to see if the rest of the program is working right because of this.

Any help you can give would be greatly appreciated.

Try that, I've hardly tested it, but I hope it helps.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MoneyCalculator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public enum moneyvalues
        {
            dollar = 100,
            quarter = 25,
            dime = 10,
            nickel = 5,
            penny = 1,
        }

        private void button1_click(object sender, EventArgs e)
        {

            int dolcnt = 0;
            int qrtcnt = 0;
            int dmecnt = 0;
            int nklcnt = 0;
            int pnycnt = 0;

            string text = string.Empty;


            string ida = textBox1.Text;
            decimal nda = (decimal.Parse(ida) * 100);

            while ((decimal)moneyvalues.dollar <= nda)
            {
                nda = nda - (decimal)moneyvalues.dollar;
                dolcnt++;
            }

            while ((decimal)moneyvalues.quarter <= nda)
            {
                nda = nda - (decimal)moneyvalues.quarter;
                qrtcnt++;
            }

            while ((decimal)moneyvalues.dime <= nda)
            {
                nda = nda - (decimal)moneyvalues.dime;
                dmecnt++;
            }

            while ((decimal)moneyvalues.nickel <= nda)
            {
                nda = nda - (decimal)moneyvalues.nickel;
                nklcnt++;
            }

            while ((decimal)moneyvalues.penny <= nda)
            {
                nda = nda - (decimal)moneyvalues.penny;
                pnycnt++;
            }

            text = ("You have " + (dolcnt.ToString()) + " dollar bill(s), " + (qrtcnt.ToString()) + " quarter(s), " + (dmecnt.ToString()) + " dime(s), " + (nklcnt.ToString()) + " nickel(s), " + (pnycnt.ToString()) + " pennies!");
            
            textBox2.Text = text;
        }
    }
}
commented: Awesome help, can not thank you enough. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.