ChangeCalculator Program C++
September 20, 2015 ยท View on GitHub
#include
using namespace std;
int main() { //reads from input file, or takes user input. 1st is your total amount, and the second is how much you paid double total; //get change cin >>total;
double paid;
cin >> paid;
double change = paid - total;
if(paid > total)
{
int quarters = change/.25;
int dimes = (change - .25*quarters)/.10;
int nickels = (change - .25*quarters - .10*dimes)/.05;
int pennies = (change - .25*quarters - .10*dimes - .05*nickels)/.01;
cout <<"Q: " << quarters << endl;
cout <<"D: " << dimes <<endl;
cout <<"N: " << nickels <<endl;
cout <<"P: " << pennies << endl;
}
else
cout << "You can't pay less than the total, now you owe money.";
}
}