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
1 punto
sergey [27]

Answer:

c Proceso productivo

Explanation:

3 0
3 years ago
4. In paragraph 7, what is the meaning of the phrase "not
galben [10]

Answer:

you need to give context of the situation

7 0
2 years ago
your manager asked you to set up a secure network connection at a remote site to move over some back ups. what protocol what do
Ivan

The protocol that should be used to establish a secure network connection for backups is SSH.

<h3>Secure Shell</h3>

SSH stands for <u>Secure Shell</u>. SSH is a <u>protocol that allows users to remotely control and modify servers</u>. SSH is commonly used by administrators to manage certain systems or applications remotely. So the admin can enter the computer via the network, then run various commands to modify or manage files from one computer to another.

SSH has several crucial functions for managing data transfer traffic. Specifically, the following are the functions and benefits of SSH:

  • Securing remote access to SSH-enabled systems or network devices for the user and processing them automatically.
  • SSH will automatically terminate the connection if there is suspicious activity on the connection used. So you can avoid various cyber threats such as IP and DNS spoofing, data manipulation, illegal tracking, and others.
  • Perform automatic and secure file transfers.
  • Launch commands securely on remote devices or systems.
  • Perform secure component management of network infrastructure.

Learn more about Secure network connection: brainly.com/question/28083478

#SPJ4

8 0
1 year ago
When a user receives an email warning about the dire consequences of possible virus attacks on their pc or tablet, it is often a
Sliva [168]
Sometime it's a scam an sometimes it's true
7 0
3 years ago
To create a datetime object for the current date and time, you can use theGroup of answer choicestoday() method of the date clas
SVEN [57.7K]

var theDate = new DateTime (DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, hours, minute, second);

6 0
2 years ago
Other questions:
  • Consider this data sequence: "fish bird reptile reptile bird bird bird mammal fish". let's define a singleton to be a data eleme
    5·1 answer
  • ANSWER THIS CORRECTLY FOR BRAINLIEST
    13·2 answers
  • A Network Attached Storage device is good for _____.
    11·2 answers
  • How many hosts are in each subnet?
    15·1 answer
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • Suppose you own a travel agency in a large city. You have many corporate clients, but growth has slowed somewhat Some long-term
    15·1 answer
  • As a general rule, the number of bullet points on a slide should not exceed _____. a.2 b.4 c.8 d.10
    9·1 answer
  • Is it possible to have a deadlock involving only oneprocess? Explain your answer.
    11·1 answer
  • Hey guys im just curious.... whats ur favorite number
    6·2 answers
  • ____must cooperate with each other to neutralize the global threat of information censorship. Select 3 options.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!