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
Make a hierarchical directory structure under /root that consists of one directory containing three subdirectories.
Alika [10]
You can make a hierarchical directory structure under /root that consists of one directory containing subdirectories  by using cd and mkdir
the mkdir command created the directories while the cd command changes which directory you're currently in
5 0
2 years ago
2.Use loops to create a 4X6 matrix in which the value of each element is two times its row number minus three times its column n
DiKsa [7]

Answer:

for(i=0; i<4; i++)

{

      for(j=0;j<6;j++)

      {

               A[ i ][ j ] = 2* i - 3*j;

      }

}

Explanation:

In this loop for each i = 0,1,2,3 we fill the the corresponding column values. and then move to next i value i.e. row.

3 0
3 years ago
What considerations should you make when deciding on the size of a table?
Kisachek [45]

Answer:

You should consider the number of cells needed for data, labels, titles, and formulas.

Explanation:

4 0
2 years ago
What is the full path and filename for the file on a Debian Linux distribution that displays the time zone settings?
lesya [120]

Answer:

/etc/timezone

Explanation:

Debian based Linux distribution is a free distribution software and an operating system. It is composed of a open source and free source software. It is one of the most popular distributions.

A computer file name is a unique system of identifying the computer stored file in the file system. The names of the different file system have different formats or extensions in the file name and imposed different file restrictions.

In the context, the full path and the file name of a file that displays a time zone settings on a Debian Linux distribution is " ../etc/timezone".

3 0
2 years ago
Technology can help governments handle economic emergencies, such as the reliance on automation. Crop and resource shortages. Th
uranmaximum [27]

Answer

Technology can help government handle economic emergencies such as crop and resource shortages.

Explanation

The government can address the concerns of food shortages and water scarcity through embracing new technology interventions to increase farm yields and mitigate the impacts of water shortages. Through crop protection methods, weeds and pest can be controlled. Drip irrigation technology applies water directly to the roots of crops to facilitate high crop production. Other technologies to apply can include organic agriculture and integrated soil fertility management.



3 0
2 years ago
Read 2 more answers
Other questions:
  • How do you delete text from a slide
    14·2 answers
  • How can I code this in Python with only if-statements? (Only allowed to use the built-in functions int(), float(), and str().)
    8·1 answer
  • Some of the more important __________ include anti-virus (and anti-malware), host-based firewall, system hardening (removing unw
    11·1 answer
  • You are a developer for a company that is planning on using the AWS RDS service. Your Database administrator spins up a new MySQ
    7·1 answer
  • What is the value of the average variable after the following code is executed? var sum = 0; var prices = [14, 10, 9, 12, 11, 14
    14·1 answer
  • C:\windows\system32\drivers\etc\protocol is an example of a file ________. select one:
    5·1 answer
  • When installing EMT conduit that will be exposed to wet conditions, _______ fittings should be used.
    5·2 answers
  • How to boost audio live ​
    10·1 answer
  • A friend asks you to look over the code for an adventure game and help figure out why it won’t work. Which of these options is s
    5·2 answers
  • The concepts of ________________, _________________, and _________________ for covert acts are pivotal to understanding state-on
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!