Question: #include using namespace std; int main() { //declare variables double dollarAmount; int quarters, dimes, nickels, pennies, totalCents; //Prompt the user to enter the amount of

#include

using namespace std;

int main() { //declare variables double dollarAmount; int quarters, dimes, nickels, pennies, totalCents;

//Prompt the user to enter the amount of money they have before the conversion cout << "Due to the Martian Money Weevel plague, we need to turn your money into all coins. "; cout << "Please enter the amount of money you have so that you don't break the law. $"; cin >> dollarAmount;

//turn the dollar amount into cents totalCents = dollarAmount * 100; //calculate and store the amount of full quarters in the amount quarters = totalCents / 25; //calculate and store the remaining change totalCents = totalCents % 25; //calculate and store the amount of full dimes in the remaining change dimes = totalCents / 10; //calculate and store the remaining change totalCents = totalCents %10; //calculate and store the amount of full nickels in the remaining change nickels = totalCents / 5; //calculate and store the remaining amount into pennies pennies = totalCents%5;

//Print the amount of each type of coin to give the smallest amount of change cout << "Alright this is the least amount of change I can give you: "; cout << quarters << " Quarter(s) "; cout << dimes << " Dime(s) "; cout << nickels << " Nickel(s) "; cout << pennies << " Pennie(s)";

return 0; }

/* Sample run Due to the Martian Money Weevel plague, we need to turn your money into all coins. Please enter the amount of money you have so that you don't break the law. $123.44 Alright this is the least amount of change I can give you: 493 Quarter(s) 1 Dime(s) 1 Nickel(s) 3 Pennie(s) Process returned 0 (0x0) execution time : 2.330 s Press any key to continue. */

I can't figure out whats wrong with my program. It keeps rounding incorrecltly for the pennies.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!