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
Korolek [52]
3 years ago
12

Write a program that helps a young student learn to make change. Use the random number generator to generate change amounts betw

een1¢ and 99¢. Ask the user how many quarters, dimes, nickels and pennies they need to make that amount. Determine whether the coins specified by the user total the specified amount and give them feedback on their answer including whether they used the minimum or optimum number of coins to produce the amount.
Computers and Technology
1 answer:
erastovalidia [21]3 years ago
6 0

Answer:

#include <iostream>

#include <stdlib.h>

using namespace std;

int main()

{

srand(time(0));

 

int coins = rand()%99 + 1;

int temp = coins;

cout<<"Enter the coins needed to make $0."<<coins<<"?"<<endl<<endl;

int a, b, c, d;

cout<<"Quarters? ";

cin>>a;

cout<<"Dimes? ";

cin>>b;

cout<<"Nickles? ";

cin>>c;

cout<<"Pennies? ";

cin>>d;

 

int quarters = coins/25;

 

coins = coins%25;

 

int dimes = coins/10;

 

coins = coins%10;

 

int nickles = coins/5;

coins = coins%5;

 

int pennies = coins/1;

 

if(((a*25) + (b*10) + (c*5) + (d*1))==temp)

{

cout<<"That's correct"<<endl;

 

if(a!=quarters || b!=dimes || c!=nickles || d!=pennies)

{

cout<<"The optimized solution is "<<endl;

}

}

else

{

cout<<"Not correct"<<endl;

cout<<"The solution is "<<endl;

 

}

 

cout<<"\tQuarters: "<<quarters<<endl;

cout<<"\tDimes: "<<dimes<<endl;

cout<<"\tNickles: "<<nickles<<endl;

cout<<"\tPennies: "<<pennies<<endl;

return 0;

}#include <iostream>

#include <stdlib.h>

using namespace std;

int main()

{

srand(time(0));

 

int coins = rand()%99 + 1;

int temp = coins;

cout<<"Enter the coins needed to make $0."<<coins<<"?"<<endl<<endl;

int a, b, c, d;

cout<<"Quarters? ";

cin>>a;

cout<<"Dimes? ";

cin>>b;

cout<<"Nickles? ";

cin>>c;

cout<<"Pennies? ";

cin>>d;

 

int quarters = coins/25;

 

coins = coins%25;

 

int dimes = coins/10;

 

coins = coins%10;

 

int nickles = coins/5;

coins = coins%5;

 

int pennies = coins/1;

 

if(((a*25) + (b*10) + (c*5) + (d*1))==temp)

{

cout<<"That's correct"<<endl;

 

if(a!=quarters || b!=dimes || c!=nickles || d!=pennies)

{

cout<<"The optimized solution is "<<endl;

}

}

else

{

cout<<"Not correct"<<endl;

cout<<"The solution is "<<endl;

 

}

 

cout<<"\tQuarters: "<<quarters<<endl;

cout<<"\tDimes: "<<dimes<<endl;

cout<<"\tNickles: "<<nickles<<endl;

cout<<"\tPennies: "<<pennies<<endl;

return 0;

}

Explanation:

  • Use the built-in rand function to generate a random coin.
  • Get all the required values for quarters, dimes, nickles and pennies and store them in variables.
  • Check if the coins give a value of temp, then answer is correct and the values of user will be added.
  • Optimum solution is displayed  If it does not matches with the optimum solution. Display that the answer is wrong along with solution.
You might be interested in
. Create an abstract Dollar class with two integer attributes, both of which are non-public (Python programmers - it is understo
aksik [14]

Answer:

Explanation:

The following code is written in Java. It creates the abstract dollar class that has two instance variables for the dollars and the coins that are passed as arguments. The test output can be seen in the picture attached below.

class Dollar {

   int dollars;

   double coin;

   private Dollar(int dollar, int coin) {

       this.dollars = dollar;

       this.coin = Double.valueOf(coin) / 100;

   }

   

}

4 0
3 years ago
What do you call a collection of pre-programmed commands and functions used in programs?
Keith_Richards [23]

Answer:

<h2><em>Heya</em><em> </em><em>Buddy</em><em>.</em><em>.</em></h2>

Explanation:

<em>A computer program is a collection of instructions that can be executed by a computer to perform a specific task. ... A collection of computer programs, libraries, and related data are referred to as software.</em>

<em>Hope</em><em> </em><em>that</em><em> </em><em>helps</em><em> </em><em>you</em><em> </em><em>dear</em><em>.</em><em>.</em>

<em>Bye</em><em>!</em>

6 0
3 years ago
Methods can be ____ correctly by providing different parameter lists for methods with the same name.
Serjik [45]
To complete the sentence - Methods can be overload methods correctly by providing different parameter lists for methods with the same name. 

Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions.
7 0
3 years ago
Qual foi o primeiro computador no mundo a ser criado e qual é a hitória por trás?
Bess [88]

Answer:

Espero que isso ajude você!

Explanation:

O ENIAC foi inventado por J. Presper Eckert e John Mauchly na Universidade da Pensilvânia e começou a construção em 1943 e só foi concluído em 1946. Ocupava cerca de 1.800 pés quadrados e usava cerca de 18.000 tubos de vácuo, pesando quase 50 toneladas.

4 0
3 years ago
How do you erase data from your hard drive
fgiga [73]
The theory that your data is still recoverable by forensic analysis by well-financed governments, is based on a misunderstanding of a research paper from the mid 90s by Peter Gutmann, which looked at MFM floppy disks, not modern EPRML hard drives. Lifehacker describes the software that you will be using, Darik's Boot and Nuke, as "an open-source boot disk utility (read: works on nearly any computer) that supports a wide variety of disk wiping methods and operates from inside the computer's RAM, allowing it to scrub the disk thoroughly at a remove.
7 0
3 years ago
Other questions:
  • Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum;
    7·1 answer
  • Which computer port transmits audio and video without the need for compression?
    6·1 answer
  • What is the name of the process of heat transfer in which heat is transmitted through light waves?
    7·2 answers
  • c++ 2.30 LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefi
    10·1 answer
  • So I was wondering how I should get into Game Development?
    12·1 answer
  • In Microsoft Access, what happens when you save a query once and run it but then add more to the query? What will happen? a)erro
    12·1 answer
  • You are late in the preparation of the computer graphics for your final report and presentation. You run into a friend who is gr
    13·1 answer
  • A(n) is the tool that will help you the most when developing the content you will use in your presentation.
    10·1 answer
  • What is digital scavenger hunting? A. An application that locates addresses B. A scavenger hunt where players use GPS and digita
    5·1 answer
  • What are impacts of ict in every day your life?describe if prifely​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!