Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will calculate the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents

Write a program that will calculate the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and one dollar, in 5 cent increments (25, 30, 35, 40...), and the machine only accepts a single dollar bill as payment.

If a price that is less than 25 cents or more than 1 dollar is entered, an error message should be displayed. An error message should also be displayed if a cost is entered which is not a multiple of 5.

The following is an example of what your MIGHT see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. The user's values are shown below in italics:

Enter the price of the item. (from 25 cents to a dollar, in 5-cent increments): 45 You bought an item for 45 cents and gave me a dollar, so your change is: 2 quarter(s), 0 dime(s), and 1 nickel(s).

Here is another example run of the program:

Enter the price of the item. (from 25 cents to a dollar, in 5-cent increments): 10 Error: Minimum price is 25 cents

Here is another example run of the program:

Enter the price of the item. (from 25 cents to a dollar, in 5-cent increments): 105 Error: Maximum price is 100 cents

Here is another example run of the program:

Enter the price of the item. (from 25 cents to a dollar, in 5-cent increments): 56 Error: Price must be in 5-cent increments

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions