Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ programming This program simulates a computerized vending machine, in which the user picks a candy type from three options. Each candy type has

in c++ programming image text in transcribed
This program simulates a computerized vending machine, in which the user picks a candy type from three options. Each candy type has a different cost As part of the programa output, you should present the following table: Candy A - 50 cents Candy B - 60 Candy C - 75 The user should select one of the following candy types (A, B, or C). Afterwards, you should also ask the user to enter a candy name. The candy name is a string and has no matching to the candy type. Once you have selected a valid candy type and entered a candy name, the computer will ask the user to enter a coin. The user should continue to ask for coins until the cost of the candy has been met. The computer should only accept valid coins, which are quarter, dime, or nickel (25, 10,5). To finalize the transaction, the candy machine should present the candy name, a detailed amount of coins entered and the amount of change if necessary. Remember, it the user enters more money than the cost of the candy, he/she should get back change This program needs a counter for each type of coin, since the output should display the amount of quarters, dimes and nickels the user entered. For example, if the user selected Candy A, he/she needs to enter 50 cents. How many coins are entered varies on the input . The cost could be distributed as 2 quarters or 10 nickles or 5 dimes with no change. There are many possible combinations, which could involve change back in the program assignment, you should use functions with parameters. You need both types of parameters by value and by reference. The key in the coding is the adequate use of parameters in the functions created. That the functions can be reused with the parameters to determine its outcome. Remember the Candy Machine only accepts valid coins such as 5.10 or 25. no cents. This variable should be int not float The programmer should validate the input of the coins and that the user can continue inputting valid coins The counters should not take into consideration when an invalid coin is entered After displaying the Candy's name the program should display only the amount of the coins entered. In other words. If you enter only quarters, the output should not show dimes and nickels. The program should display the amount of change, only if the money exceeds its cost. The program should be able to repeat itself where the user enters that option through input

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions