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]
3 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]3 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
Select the correct answer from each drop-down menu. Computer memory stores data as a series of 0s and 1s. In computer memory, re
attashe74 [19]

Answer:

Zero (0); one (1).

Explanation:

Boolean logic refers to a theory of mathematics developed by the prominent British mathematician, called George Boole. In Boolean logic, all variables are either true or false and are denoted by the number "1" or "0" respectively; True = 1 or False = 0.

The memory of a computer generally stores data as a series of 0s and 1s. In computer memory, zero (0) represents the absence of an electric signal i.e OFF and one (1) represents the presence of an electric signal i.e ON.

4 0
3 years ago
Helppp pleaseee help pleaseee look at picture
ale4655 [162]

Answer:

C & E

Explanation:

Brainlest, Please!

4 0
11 months ago
Read 2 more answers
What type of software repairs or improves a larger application that is already installed on a system?
earnstyle [38]

Answer:

<h2>Mapping</h2>

Explanation:

<h2>Hope it helps you</h2>
7 0
2 years ago
Read 2 more answers
"open workbench can exchange files with microsoft project by importing and exporting the data in ____ file format."
Leviafan [203]
I believe the answer to this question is XML
5 0
2 years ago
________ is the relative value, either in monetary terms or in overall impact, of the resource being protected by the access con
kherson [118]

Answer:

a. Asset value

Explanation:

Asset value is the value of a share in the company.

The asset value is calculated as

= [ Difference between the total of its assets and its liabilities ] ÷ [ The number of ordinary shares issued ]

The asset value may also be the equal as the book value or the it may be same as equity value of a business.

3 0
2 years ago
Other questions:
  • Which best describes the relationship between maximum cost-per-click (max. cpc) bids and ad rank?
    12·1 answer
  • When Clara accesses the programs and documents on her computer by way of icons, she is said to be employing
    15·1 answer
  • Fifty part-time students were asked how many courses they were taking this term. The (incomplete) results are shown below. Need
    6·1 answer
  • Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grade
    10·1 answer
  • Jack wants to save his PowerPoint file electronically. He should store his file in:
    6·2 answers
  • Which statement gives an advantage of multicellular organisms?
    7·2 answers
  • HELP!!!
    11·2 answers
  • Is it okay for potential employers to search your social media for use in determining if you are a fit for the position?
    15·1 answer
  • name instances in the past where social media has kept you informed about the latest news around the country​
    15·2 answers
  • 3. Special keys labelled Fl to F12.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!