In: Computer Science
make a c++ program that calculates the amount left from a value of money of one dollar bill or less in quarters, dimes, nickels, and pennies. The remaining value can be shown in cents knowing that in cents:
penny = 1
nickel = 5
dime = 10
quarter = 25
If you have any doubts, please give me comment...
#include <iostream>
using namespace std;
int main()
{
int amount, quarters = 0, dimes = 0, nickels = 0, pennies = 0;
cout << "Enter amount left from one dollars bill(in cents): ";
cin >> amount;
if (amount > 99)
cout << "please enter an amount less than one dollar" << endl;
else
{
quarters = amount / 25;
amount %= 25;
dimes = amount / 10;
amount %= 10;
nickels = amount / 5;
amount %= 5;
pennies = amount;
cout << "quarters: " << quarters << endl;
cout << "dimes: " << dimes << endl;
cout << "nickels: " << nickels << endl;
cout << "pennies: " << pennies << endl;
}
return 0;
}