Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an algorithm that asks the user to enter an amount of money, and the progr

ID: 3648312 • Letter: W

Question

Write an algorithm that asks the user to enter an amount of money, and the program will output how many bills/coins are needed for this amount. Example: the user enters the number 8748, and the program will reply: 1x5000, 1x2000, 1x1000, 1x500, 2x100, 4x10, 1x5, 3x1 (note: no coin with the value 50 is used in this example, and is therefore omitted from the output in this example, but should be included otherwise).

Explanation / Answer

fivethousand=twothousand=thousand=fivehundred=dundred=fifty=twenty=ten=five =one=0 //all the other values, also change = bill; while( change > 0) { if(change > 5000) {fivethousand++; change -=5000; continue; } if(change > 2000) {twothousand++; change -= 2000; continue; } if(change > 1000) {thousand++; change -= 1000; continue; } if(change > 500) {fivehundred++; change -= 500; continue; } if(change > 100) {hundred++; change -= 100; continue; } //repeat for all denominations, right down to the penny if(change > 0) } coins = pennies+(nickels*5)+(dimes*10)+(quarters*25); bills = dollars +(fives*5)+ etc. printf("Your change: %d.%2d", bills.coins);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote