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]
2 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]2 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
What port is typically reserved and utilized by the Secure Hypertext Transfer Protocol to create a secure connection to a Web se
jek_recluse [69]

Answer:

Port 443

Explanation:

This is the Hypertext Transfer Protocol Secure that combines the HTTP with a cryptographic protocol, which can be used for payment transactions and other secure transmission of data from Web pages. Whenever you connect to a website beginning with "https://" or you see the lock icon, you’re connecting to that web server over port 443.

4 0
3 years ago
After reading the article, "The Impact of Technology", answer the following question.
kolezko [41]

Answer:

Technology has played a huge a part in terms of progressing the economies of different countries. Technology has brought into action the globalized solutions to bring people across the globe together.

Regardless of the benefits, this technology has caused people to socialize less in real life. They have found ways to entertain themselves through technology and that has effected their social interactions greatly.

3 0
3 years ago
________ is used for supervisory messages at the internet protocol layer.
Natalija [7]
"ICMP" <span>is used for supervisory messages at the internet protocol layer.
ICMP stands for </span>Internet Control Message Protocol and it refers to a supporting protocol in the Internet protocol suite. It is utilized by network devices which includes routers and these are used to send error messages and operational data showing, for instance, that asked for service which isn't accessible or that a host or switch couldn't be come to.
4 0
3 years ago
_____ create computer programs by using their knowledge of computer science, math, and other disciplines.
zimovet [89]
B.) Software designers
5 0
3 years ago
Which of the following techniques would a Baroque composer most likely employ to evoke an affect of agitation? Select one:
frez [133]

Answer:

b. Rubato tremolo

Explanation:

Tremolo is a modulation effect that imposes a rhythmic change in volume of sound. Once discovered in electric amplifier circuits, sound engineers and composers like the Baroque now use this low frequency oscillating modulation technique to create emotional piercing effect on their audience to maintain focus.

The low frequency tremolo can be gotten from the vibrating string in guitars, violins etc, and vocal sound, it is also produced from electronic devices created for its purpose. they are called optical tremolo.

5 0
3 years ago
Other questions:
  • To play game, go inside the Grand Theft Auto V folder and right click and runGTAVLauncher as administrator.If you get any missin
    5·1 answer
  • The ____ dialog box in windows vista appears each time a user attempts to perform an action that can be done only with administr
    12·1 answer
  • HURRY!! Ill give brainily and 25 points. Describe how Scent is related to the culture and historical period when it was created.
    15·1 answer
  • When you copy a formula that contains an absolute reference to a new location, the reference ____. a. has a dotted outline in it
    6·1 answer
  • Which guideline should you use when downloading software from the Internet?
    15·1 answer
  • What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y =50; if ( x &gt;=
    7·2 answers
  • Write a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclus
    10·1 answer
  • H e l p ASAP plz <br> and thanks
    9·1 answer
  • The function's only behavior should be to return the sum of array userVals' elements. What common error does the function make?
    6·1 answer
  • Are programs that understand physics and/or hardware embedded? for example, one that uses finite-element methods to predict flui
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!