I'm trying to create a simple change sorter program, everything is functioning properly expect for the part that's suppose to detect quarters.
Example of current output:
The amount you entered is: 52.50
You have this many Fifty dollars: 1
You have this many Ten dollars: 0
You have this many One: 2
You have this many Quarters: 0
Desired output:
The amount you entered is: 52.50
You have this many Fifty dollars: 1
You have this many Ten dollars: 0
You have this many One: 2
You have this many Quarters: 2
I can't figure out how to adjust this, so the quarters can be read.
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
|
#include <iostream>
#include <iomanip>
using namespace std;
const int FIFTY = 50;
const int TEN = 10;
const int ONE = 1;
const int QUARTER = 0.25;
int _tmain(int argc, _TCHAR* argv[])
{
int change;
cout << "Enter the amount of money in your wallet: ";
cin >> change;
cout << endl;
cout << "The amount you entered is: " << change << endl;
cout << "You have this many Fifty dollars: " << change / FIFTY << endl;
change = change % FIFTY;
//
cout << "You have this many Ten dollars: " << change / TEN << endl;
change = change % TEN;
//
cout << "You have this many One: " << change / ONE << endl;
change = change % ONE;
//
cout << "You have this many Quarters: " << change / QUARTER << endl;
change = change % QUARTER;
return 0;
}
|
[Update] Still getting errors, even after changing the code based on feedback.
Lines [45-47] or the Quarter block must stay where it is, thought I did switch them and still got the same errors.
Those error codes by the way are:
Error 1 error C2297: '%' : illegal, right operand has type 'double'
Error2 IntelliSense: expression must have integral or unscoped enum type