Create a program that accepts numbers of pennies to make change for 387
dollars= 3
quarters=3
dimes=1
nickels=0
pennies=2
#include <iostream>
using namespace std;
int main()
{
int money, dollars, quarters, dimes, nickles, pennies;
cout << "Enter numbers of pennies to make change for: ";
cin >> money;
//find number of dollars
dollars = money/100;
money = money%100;
//find number of quarters
quarters = money / 25;
money = money % 25;
//fin number of dimes
dimes = money / 10;
money = money % 10;
//find number of nickles
nickles = money / 5;
money = money % 5;
//find number of pennies
pennies = money;
//change
cout << "Change displayed " << endl;
cout << "-------------------------------" << endl;
cout << "dollars = " << dollars << endl;
cout << "quarters = " << quarters << endl;
cout << "dimes = " << dimes << endl;
cout << "nickels = " << nickles << endl;
cout << "pennies= " << pennies << endl;
return 0;
}
Comments
Leave a comment