Question
In c++
Write a program that asks users to input the amount of money (in cents) that will be exchanged to the least number of coins of the same value, output the results. Assume there are quarters (25c), dimes (10c), nickels(5c) and pennies(1c) available. ■CA 32 cmd.e eas input the anount of money (in cents) you want to exchange 39 39 can be exchanged to uarter: 25 me: 1 kel: e enny: 4 ress any key to continue-.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student,

below i written the C++ code as per the requirement.

Please note the below program has been tested on ubuntu 16.04 system and compiled using C++ compiler. This code will also work on other iDe;'

-----------------------------------------------------------------------------------------------------------------------------------

Program:

-----------------------------------------------------------------------------------------------------------------------------------

#include<iostream>

using namespace std;

int main()

{

int cents, penny, nikel, dime, quarter;

cout<<"Please input the amount of money (in cents) you want to exchange: "<<endl;

cin>>cents;

int temp = cents;

//caonvert to different exchnage

quarter = cents/25;

cents = cents % 25;

dime = cents/10;

cents = cents % 10;

nikel = cents/5;

cents = cents % 5;

penny = cents/1;

cout<<temp<<" can be exchnaged to "<<endl;

//display the exchange

cout<<"Quarter: "<<quarter<<endl;

cout<<"Dime: "<<dime<<endl;

cout<<"Nikel: "<<nikel<<endl;

cout<<"Penny: "<<penny<<endl;

cout<<endl;

cout<<"Press any key to continue. . . "<<endl;

return 0;

}


===================================================================

Sample Output:

nirmalsharmagubuntu:-/HomeworkLib solutions/27_02_2018$ g++ exchange.cpp nirmalsharma@ubuntu:~/HomeworkLib_solutions/27_02_2018$ ./a.out

=====================================================================

Add a comment
Know the answer?
Add Answer to:
In c++ Write a program that asks users to input the amount of money (in cents)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (In Python 3) Write a program with total change amount as an integer input, and output...

    (In Python 3) Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes So...

  • Write a program called CountCoins.java that prompts the user for the input file name (you can...

    Write a program called CountCoins.java that prompts the user for the input file name (you can copy the getInputScanner() method given in the ProcessFile assignment) then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be “pennies” (1 cent each), “nickels” (5 cents each), “dimes” (10 cents each), or “quarters” (25 cents each), case-insensitively. Add up the cash values of...

  • Write a program with total change amount as an integer input, and output the change using...

    Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes

  • ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following...

    ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following two problems. Upload your source code files to Canvas. The file names must be of the form coins_your_name.cpp and bonus_your_name.cpp for problems 1 and 2, respectively. Substitute your first and last name for "your_name" in the file name. Problem Statements 1. Given a value V in cents, you need to make change using a minimum number of coins. Assume you have an infinite supply...

  • how slove 4-34, 4-35, 4-36??? I dont know that! please hlep me! 306 □ CHAPTER 4/SEQUENTIAL CIRCUITS OTABLE 4-16...

    how slove 4-34, 4-35, 4-36??? I dont know that! please hlep me! 306 □ CHAPTER 4/SEQUENTIAL CIRCUITS OTABLE 4-16 State Table for Problem 4-33 Next State Input Output Present State 4-36 4-37 0 0 0 0 4-38 Design the circuit specified by Table 4-14 and use the sequence from Problen 4-31 (either yours or the one posted on the text website) to perform an automatic logic simulation-based verification of your design. 4 433. The state table for a sequential circuit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT