|
1st time CPP help
i need to create a program which will break down an amount of money into: dollars, quarters, dimes, nickels, and pennies.
for instance $5.36= 5 dollars, 1 quarter, 1 dime, and 1 penny.
i played around a bit but i reached a point where i was stuck. i ended up with 2 sets of input/output statements. i need only one but once i remove the other the program ceases to function. basically i need "enter the change amount" as the intput and "change" as the input.
here's the portion of code that is troubling me:
int main()
{
float change;
int changeneeded;
int quarters=40, dimes=50, nickels=40, pennies=50;
int numq, numd, numn, nump;
cout <<"Enter the change amount: " ;
cin >>change;
while(change>0)
{
cout << "Enter the change amount: ";
cin >> change;
cout << ((int)(change*100))/100 << " dollar bills ";
changeneeded = ((int)(change*100))%100;
compute_coin(25, numq,changeneeded);
compute_coin(10, numd,changeneeded);
compute_coin(5, numn,changeneeded);
compute_coin(1, nump,changeneeded);
quarters-=numq;
dimes-=numd;
nickels-=numn;
pennies-=nump;
--any help would be greatly appreciated. thanks.
|