Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The machine starts with 10 quarters, 20 dimes, and 30 nickels. Needs to: -> Have a function that displays all the items and their prices,

image text in transcribedThe machine starts with 10 quarters, 20 dimes, and 30 nickels.

Needs to:

-> Have a function that displays all the items and their prices, prompts the user to enter their choice. Use a sentinel value to "Cancel the order".

-> The user can only purchase 1 item one at a time.

-> In order function, prompt the user to enter the amount of money needed. And, one or more functions to accept input and keep track of change.

-> User can only enter nickels, dimes, quarters and dollar bills. For example, Let's say something costs $0.60. Prompt the user to enter $0.60. The user can only enter nickels, dimes, quarters, or dollar bills. Don't accept anything else. In other words, the user cannot simply type 60 or .60. As long as the amount entered is less than the amount needed, the user should be prompted for the amount still needed. So for $0.60, if the user first enters a quarter, then you should say something like: Please enter $0.35 cents. If the user enters too much (i.e they use 3 quarters), then you will need to give them back a dime and nickel change. You must give the change in coins, NOT as $.15 or 15. In addition, you cannot return change if you don't have the correct change in the machine! (If you have no dimes in this example, you will have to return 3 nickels; if you have only 2 nickels and no dimes, you will have to refund all the money and keep the purchase.)

-> Randomly reject a dollar bill if one is entered.

-> ask the user if they would like to purchase another item (until they enter a sentinel value)

-> Keep track of how many of each item has been sold. If an item is sold out indicate that it is sold out in the menu. At the end of the program print a table of the items sold like this:

Candy Bar 3

Energy Bar 5

Energy Drink. 2

Etc.

-> At the end of the program, the total amount of money put into the machine, and how many dollar bills, quarters, nickels, and dimes there are in the machine. At the end of the program, write a text file of the items sold, and the total (I.e all of 3 and 4 into a text file.) the text is named after VendingMachine.txt.

There should be functions, constant literals (numbers as well as strings), formatted output of information, switch statements, loops, arrays, conditionals, file input and output.

The machine holds 8 different items: The machine starts with 10 quarters, 20 dimes, and 30 nickels. You need to: Have a function that displays all the items and their prices, prompts the user to enter their choice. Use a sentinel value to "Cancel" the order. The user can only purchase 1 item at a time. In another function, prompt the user to enter the amount of money needed. And, one or more functions to accept input and keep track of change. Users can only enter nickels, dimes, quarters, and dollar bills. Let's say something costs $0.60. Prompt the user to enter $0.60. The user can only enter nickels, dimes, quarters, or dollar bills. Do not accept anything else. (In other words, the user cannot simply type 60 or.60.) As long as the amount entered is less than the amount needed, the user should be prompted for the amount still needed. So for $0.60, if the user first enters a quarter, then you should say something like: Please enter $0.35 cents. If the user enters too much (i.e. they use 3 quarters), then you will need to give them back a dime The machine holds 8 different items: The machine starts with 10 quarters, 20 dimes, and 30 nickels. You need to: Have a function that displays all the items and their prices, prompts the user to enter their choice. Use a sentinel value to "Cancel" the order. The user can only purchase 1 item at a time. In another function, prompt the user to enter the amount of money needed. And, one or more functions to accept input and keep track of change. Users can only enter nickels, dimes, quarters, and dollar bills. Let's say something costs $0.60. Prompt the user to enter $0.60. The user can only enter nickels, dimes, quarters, or dollar bills. Do not accept anything else. (In other words, the user cannot simply type 60 or.60.) As long as the amount entered is less than the amount needed, the user should be prompted for the amount still needed. So for $0.60, if the user first enters a quarter, then you should say something like: Please enter $0.35 cents. If the user enters too much (i.e. they use 3 quarters), then you will need to give them back a dime

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago