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
LUCKY_DIMON [66]
4 years ago
14

Write an algorithm and a C++ program that determines the change to be dispensed from a vending machine. An item in the machine c

an cost between 25 cents and a dollar, in 5-cent increments (25, 30, 35, … , 90, 95, or 100), and the machine accepts only a single dollar bill to pay for the item. The program asks the user to enter the price of the item. Then, the program calculates and outputs the change as illustrated in the sample outputs bellow.
Computers and Technology
1 answer:
hoa [83]4 years ago
8 0

Answer:

// program that implement the algorithm to find the change.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int cost,q,d,n,p;

   cout<<"Enter the cost of item between 25 cents and a dollar, in 5 increments (25, 30, 35, … , 90, 95, or 100):";

   // read the cost

   cin>>cost;

   // find the change

   int change=100-cost;

   // find quarter

   q=change/25;

   change=change%25;

   // find the dimes

   d=change/10;

   change=change%10;

   // find the nickels

   n=change/5;

   // find the pennies

   p=change%5;

   // print the change

   cout<<"Your change is: "<<q<<" quarter,"<<d<<" dimes,"<<n<<" nickels and "<<p <<" pennies."<<endl;

return 0;

}

Explanation:

Read the cost of item from user and assign it to variable "cost".Then find the change to be returned to user.Then find the quarter by dividing the change with 25.Update the change and then find the dimes by dividing change with 10.Then update the change and find nickels and then find the pennies.Print the change to be returned.

Output:

Enter the cost of item between 25 cents and a dollar, in 5 increments (25, 30, 35, … , 90, 95, or 100):45

Your change is: 2 quarter,0 dimes,1 nickels and 0 pennies.

You might be interested in
Yahoo Messenger is an example of a/an __________ service on the Internet.
barxatty [35]

Answer:

Yahoo Messenger is an example of a service on the Internet.

7 0
3 years ago
Read 2 more answers
In an input file, what maintains the location of the next item that will be read from the file?
Semmy [17]

The Read Position marks the location of the next item that will be read from the file.

6 0
4 years ago
nhập N số nguyên dương vào dãy A: a1,a2,...an. Xuất ra số lượng các phần tử số dương và số âm trên dẫy A
DIA [1.3K]

Answer:

????????

Explanation:

???!?!! okay okay okay

7 0
3 years ago
Who want followers on Instagram... gotta follow back
Alexxx [7]

Explanation:

I dont have Instagram....

6 0
3 years ago
Read 2 more answers
. Html documents are created by adding what to text?
zvonat [6]
The answer is Tags, sorry about putting the other answer misread question.
7 0
3 years ago
Other questions:
  • Required
    12·1 answer
  • To rotate text in a cell, select the _____ option in the alignment grouping.
    8·1 answer
  • Malcolm is part of a team developing a new smartphone app to track traffic patterns. Because team members are located throughout
    12·1 answer
  • Which feature enables you to make changes to all the slides of your presentation at the same time?
    15·2 answers
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is
    5·1 answer
  • In a print statement, you can set the ________ argument to a space or empty string to stop the output from advancing to a new li
    7·1 answer
  • Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to conv
    13·1 answer
  • Under which tab would you look to find the Show in Groups and advanced sort options for messages in Outlook?
    11·2 answers
  • Tulio is editing his video. He used the Trim Video tab. Tulio most likely changed the
    12·1 answer
  • Write a c++ program that generates three random numbers. The first number should be between 0-30, the second number should be be
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!