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
Who will help me with a test on Computer Science plz will help you level up and upvotes!!!!! plzzzzzzzzzzzzzzzzzzz
Diano4ka-milaya [45]
Sure, depends what you need help with!
5 0
2 years ago
Read 2 more answers
Which course must first-time drivers in Florida take to be eligible for their Learner License?
Travka [436]
The Traffic Law and Substance Abuse Course (TLSAE), which is also known as the drug and alcohol course.
7 0
3 years ago
Suppose we have a linearly separable dataset, and we divide the data into training and validation sets. Will a perceptron learne
Sauron [17]

Answer:

Theoretically Yes

Explanation:

The data given is linearly separable. So, the subset of the data will also be linearly separable. And it will pass for all training dataset. However, you should definitely never expect such thing In any real-life problem because the data is noisy, for a bazilion of reasons, so no model is guaranteed to perform perfectly.

3 0
3 years ago
Which of the following is not an advantage of concurrent design?
viva [34]

The answer I believe is B

7 0
3 years ago
Read 2 more answers
When creating an electronic slide presentation, Lee should avoid
Amanda [17]

I believe the answer is <u>Using sound effects between slides.</u>

Using sound effects between slides can cause for a distraction, and if you are in college, your professor may not score your presentation as well as if it were made without sound effects. Hope this helps!

5 0
2 years ago
Other questions:
  • Which component is the smallest unit in a spreadsheet?
    14·2 answers
  • Up to 10 people is a good guideline for the size of your study group.
    15·1 answer
  • . Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
    15·1 answer
  • True or false: within a database, fields can be added, deleted and edited but never moved.
    11·1 answer
  • After you set a pin for a domain account on your laptop, that pin can be used only on your laptop. question 17 options:
    7·1 answer
  • Which of the following code segments could be used to skip the first two characters of an input line (they may or may not be whi
    13·1 answer
  • Harmful programs used to disrupt computer operation, gather sensitive information, or gain unauthorized access to computer syste
    7·1 answer
  • Writing a function that implements a loop to collect a set amount of data. The function should use the serial object, the record
    9·1 answer
  • Which two components are configured via software in order for a PC to participate in a network environment
    5·1 answer
  • Chantelle wants to change the color scheme for her company's web app, and she needs to get the logos updated. What kind of devel
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!