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
Look at the picture lol
andrey2020 [161]

Answer:

Zoom in more please and than i can help

Explanation:

6 0
2 years ago
Read 2 more answers
Which type of books contains snapshots of steps that help to perform an activity?
stellarik [79]

Answer:

online book,,.........,.

5 0
3 years ago
Read 2 more answers
By default, Outlook displays messages in the Content pane grouped by the
goldfiish [28.3K]

Answer:

By default, Outlook orders messages in the Content pane grouped by dates the messages were received and sorted with the oldest message at the top of the list.

Explanation:

8 0
2 years ago
Write switch-case statement that displays the following information if the temperature is the input Activities at Lake LazyDays
Marta_Voda [28]

Answer:

//here is code in c++.

#include <bits/stdc++.h>

using namespace std;

int main()

{

// variable

int temp;

cout<<"Please enter the temperature:";

//read temperature from user

cin>>temp;

int n;

// reduce the case for switch

n=temp/10;

// print output according to the switch case

switch (n) {

case 7:

case 6:

cout<<"tennis"<<endl;

break;

case 5:

case 4:

cout<<"golf"<<endl;

break;

default:

if(temp>=80)

cout<<"swimming"<<endl;

else

cout<<"skiing"<<endl;

break;

}

return 0;

}

Explanation:

Read the value of temperature from user and assign it to variable "temp".

Calculate n=temp/10, to limit the number of cases in the switch statement.

if temperature is greater or equal 60 & less than 80, it will print "tennis".

If temperature is greater or equal 40 & less than 60, it will print "golf".

in default case, if temperature is greater than 80, it will print "swimming".

if less than 40, print "skiing".  

Output:

Please enter  the temperature::67                                                                                        

tennis

3 0
3 years ago
Write an if statement that prints the message “Application accepted” if the variable workExperience is greater than or equal to
katovenus [111]
If workExperience >= 2 or CollegeDegree is true:
print “Application accepted”
else:
print “Application denied”

4 0
3 years ago
Read 2 more answers
Other questions:
  • The part of the computer that contains the brain or central processing unit is also know as the
    15·2 answers
  • A type of specialty processor devoted exclusively to protecting your privacy.
    9·2 answers
  • Ryan is the operations manager for a national financial company. His company is in the process of creating a customer handbook.
    13·1 answer
  • You have a number of digital pictures you recently took on your smartphone. You would like to share these pictures with all of y
    9·2 answers
  • Why did Hunter gatherers moved into the<br>America's?​
    8·1 answer
  • Tara needs to select all of the text in a Word document. Which keyboard shortcut will achieve this goal?
    9·2 answers
  • Is the internet a private place?
    15·2 answers
  • What are the five types of docs you can create an share with google docs
    7·2 answers
  • How do hardware and software work together to allow a user to perform a function?
    7·2 answers
  • Very few games have any sort of narrative, not even a simple one that involves setting the mood through color, sound, environmen
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!