Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

tried to fix issues and other answer expert gave had typos please help and take time to not have typos... #include #include using namespace std;

tried to fix issues and other answer expert gave had typos please help and take time to not have typos...

#include #include using namespace std;

{ int total = quarters * 25 + dimes * 10 + nickels * 5; //total amount of coins cout << "You have $" << total / 100 << " and " << total % 100 << " cents." << endl; //print out the dollar amount }

int main() { const int QUARTER = 25; const int DIME = 10; const int NICKEL = 5; const int PENNY = 1; int choice; int q = 0, d(0), n(0), p(0), g(0); //for determining d for dimes, q=quaters, n=nickels, p=pennies, t=total in cents double c;//for cents $.$$ input do { cout << " Choose 1 to input dollar amount to get coins. " << "Choose 2 to input coins and get dollar amount " << "Choose 3 to exit this program " << "Enter your choice and press Return: "; cin >> choice; switch (choice) { case 1:

cout << "Please input dollar amount (*.**) positive numbers only and keep it reasonable of course: "; cin >> c; cout << "you have put $" << c << " in system to calculate "; g = c * 100; cout << "that is " << g << " cents ";

if (g / QUARTER >= 1) //checking for quarters { q = g / QUARTER; g = g % QUARTER; } if (g / DIME > 1) //if dimes are remaining this will be checking for dimes here { d = g / DIME; g = g % DIME; } if (g / NICKEL > 1)//if nickels are remaining this will be checking for Nickels here { n = g / NICKEL; g = g % NICKEL;

} if (g / PENNY > 1)//if pennies are remaining this will be checking for pennies here { p = g / PENNY; c = g % PENNY; } cout << " converted quarters = " << q; cout << " converted dimes = " << d; cout << " converted nickels= " << n; cout << " converted pennies = " << p;

//tried to do it another way but pennies are off, this was first way attempted... /*q = g / 25; q = q % 25; cout << "that is " << q << " quarters "; d = q / 10; d = d % 10; cout << "that is " << d << " dimes "; d = d / 5; n = d % 5; cout << "that is " << n << " nickels "; n = n / 1; p = n % 1; cout << "that is " << p << " pennies"; */ break; case 2:

{ int total = quarters * 25 + dimes * 10 + nickels * 5; //total amount of coins cout << "You have $" << total / 100 << " and " << total % 100 << " cents." << endl; //prints out the dollar amount }

int quarters, dimes, nickels; //declare variables cout << "Input quarters: "; //Input for quarters cin >> quarters; //get quarters cout << "Input dimes: "; //ask for dimes cin >> dimes; //input dimes cout << "Input nickels: "; //Input for nickels cin >> nickels; //input nickels int total = quarters * 25 + dimes * 10 + nickels * 5; //total amount of coins cout << "You have $" << total / 100 << " and " << total % 100 << " cents." << endl; //print out the dollar amount } break; case 3: cout << "End of Coin Dispensing Program\Come Again! "; break; default: cout << "Warning you Have Made an Invalid Choice Choose Again ";

}while (choice != 3); return 0;

}

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions