Answer to Question #271822 in C++ for dy20

Question #271822

Create a program that accepts numbers of pennies to make change for 387


dollars= 3

quarters=3

dimes=1

nickels=0

pennies=2


1
Expert's answer
2021-11-27T02:33:21-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS