Jun 4, 2017 at 9:08pm UTC
I try to add the value of dollars, quarters, dimes, nickels, pennys for the total monetary value but do not know how. Any help?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
int dollar;
float quarter, dime, nickel, penny;
double total;
dollar = 1;
quarter = .25;
dime = .1;
nickel = .05;
penny = .01;
// input servers name
cout << "What is your name?" ;
getline(cin, name);
//input dollars made
cout << "how many dollars did you receive" ;
cin >> dollar;
// input quarters made
cout << "Quarters received?" ;
cin >> quarter;
// input dimes
cout << "dimes" ;
cin >> dime;
// input nickel
cout << "nickels?" ;
cin >> nickel;
// input penny
cout << "pennies" ;
cin >> penny;
// input total
total = dollar + quarter + dime + nickel + penny;
cout <<total;
system("PAUSE" );
return 0;
}
Last edited on Jun 4, 2017 at 9:09pm UTC
Jun 4, 2017 at 11:03pm UTC
@TheArk
Maybe the values you're inputting, actually equals an even amount. Try making sure you use odd coin counts.
If that doesn't work, show me the values you are using, and I'll look over the code with those inputted.
Jun 4, 2017 at 11:13pm UTC
I have run the program with value of 3 dollars, 3 quarters, 3 dimes, 3 nickels, 3 pennys, with the total coming to 15, so they are not multiplying properly... I am sure it is something obvious again, appreciate the help.
Jun 4, 2017 at 11:35pm UTC
That did it, the semi colon after penny, I just overlooked it. Thanks!