1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lilit [14]
3 years ago
8

Create a change-counting game that asks the user to enter what coins to use to make exactly one dollar. The program should ask t

he user to enter the number of pennies, nickels, dimes, and quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the user for winning the game. Otherwise, the program should display a message indicating whether the amount entered was more or less than one dollar. Use constant variables to hold the coin values.
Computers and Technology
1 answer:
Mashutka [201]3 years ago
5 0

Answer:

The cpp program is given below.

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

   //constant variables holding values of coins

   const int penny=1;

   const int nickel=5;

   const int dime=10;

   const int quarter=25;

   //variables to hold user input of number of coins

   int p, n, d, q, sum;

   std::cout << "Enter the number of pennies: ";

   cin>>p;

   std::cout << "Enter the number of nickels: ";

   cin>>n;

   std::cout << "Enter the number of dimes: ";

   cin>>d;

   std::cout << "Enter the number of quarters: ";

   cin>>q;

   //total amount is computed

   sum=penny*p;

   sum=sum+(nickel*n);

   sum=sum+(dime*d);

   sum=sum+(quarter*q);

   if(sum==100)

       std::cout << "Congratulations! You won the game." << std::endl;

   else

   {

       if(sum<100)

           std::cout << "Your entered amount was less by " <<(100-sum)<< " cents. " <<std::endl;

       else

           std::cout << "Your entered amount was more by " <<(sum-100) << " cents. "<< std::endl;

   }

   return 0;

}

OUTPUT

Enter the number of pennies: 1

Enter the number of nickels: 1

Enter the number of dimes: 1

Enter the number of quarters: 1

Your entered amount was less by 59 cents.

Explanation:

1. All the values of the coins, penny, nickel, dime and quarter are declared as constant integers.

2. The variables are declared to hold user input for the number of coins of all the constant denominations.

3. Once the user enters the required values, total sum of all the coins entered by the user is computed.

4. If the total value of the coins equals 100 cents, user won the game since the user entered correct values which summed up to 100 cents or 1 dollar.

5. If the total value of the coins does not equals 100 cents, the total is either less or more than 100 cents. The required difference between the user entered coins and 1 dollar is displayed to the user and the user loses the game.

6. The entire logic for user input is placed inside main() method.

7. All the variables and constants are also declared and defined respectively inside main() method.

You might be interested in
The open items on your computer are displayed here. menu bar open bar taskbar toolbar
Dennis_Churaev [7]
Maybe the answer is the Taskbar?
8 0
3 years ago
Read 2 more answers
In addition to regular watch features, which two features are often found on smart watches?
andriy [413]
Phone capabilities and fitness monitoring
5 0
3 years ago
Which programming language was released first? FORTRAN BASIC Perl Pascal<br><br>ANSWER: FORTRAN (A)
julsineya [31]

Answer:

FORTRAN

Explanation:

  • The first programming language was FORTRAN .
  • It was released on 1957
  • About 65 years ago , when programming languages are at infant stage
8 0
2 years ago
Read 2 more answers
For a panoramic photograph, you will more than likely want to control the exposure of the photograph yourself rather than lettin
Ronch [10]
When shooting panoramic you would want to control the exposure yourself, much rather than the camera..... A panoramic is one big picture correct, so you would want all of them to be the same exposure level, now some cameras may lock on, and others may not......your correct answer would be TRUE does this make sense?
8 0
4 years ago
Mention 5 advantages of internet​
alexira [117]

Answer:

1) We can get various types of information, knowledge.

2) We can communicate with each other no matter where they are if they have internet connection.

3) It can be used as a source of entertainment.

4) Through internet, we can work from home especially in this quarantine time.

5) Through internet, we can show our talent and skills.

Hope it helps :)

If you liked it, please mark this answer as the brainliest one.

4 0
4 years ago
Other questions:
  • In databases and database-related software, which choice is not a Boolean operator?
    7·2 answers
  • A user prefers an external monitor, mouse, and keyboard for a laptop. The user does not want to use the built-in screen; however
    5·1 answer
  • You start up your laptop while getting a coffee across the room. You hear the usual chimes and doinks as it starts up. When you
    14·2 answers
  • What is the correct process for selecting an entire row in a spreadsheet?
    8·2 answers
  • In which circumstances would the view side by side feature be useful or helpful.
    15·2 answers
  • Assume that you are testing the Orders database introduced in Watt (2014) - Appendix C. Discuss the problems and possible conseq
    12·1 answer
  • The response from a Google Form can be seen in how many ways?
    10·1 answer
  • Taylor and Rory are hosting a party. They sent out invitations, and each one collected responses into dictionaries, with names o
    9·1 answer
  • Which of the following is a characteristic of vector graphics?
    15·2 answers
  • Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!