Question: Functions & Vending Machines.cpp Program Write a C++ program which will model accepting payment and giving change for a snack vending machine. The machine wl

Functions & Vending Machines.cpp Program

Functions & Vending Machines.cpp Program Write a C++ program which will modelaccepting payment and giving change for a snack vending machine. The machinewl contain the following items, shown with the label used to selectthe item, and its price: LabelItem Price P Potato Chips1.25 S Snickers

Write a C++ program which will model accepting payment and giving change for a snack vending machine. The machine wl contain the following items, shown with the label used to select the item, and its price: LabelItem Price P Potato Chips1.25 S Snickers Bar 1.35 0.95 1.50 1.75 1.40 T Pop Tart C Cookies BBrownies N Nuts This assignment does have an extra credit option. Please see the Extra Credit section below. Requirements: . Name the source file for your program program4.cpp . Throughout the program, all amounts of money must be stored internally as cents (in variables of type int) . There must be three functions with the following prototypes (Choose a naming scheme that suits you, but use these names): int menu(void); int acceptMoney (int price); int computeChange(int totalPaid, int totalPrice); These three functions must behave as follows: The function menu must display the list of snack items and prompt the user for their choice. If the user makes a valid selection, the function must return the price of that selection, otherwise the user must be re-prompted for a choice until a valid choice fronm the menu is obtained - The function acceptMoney must give the user a choice of coins to insert, and add up the total amount inserted by the user, in a loop until this total amount is equal to or greater than the function's parameter price (which is the cost of the user's choice of snack) Once this loop is complete, the function must return the total amount of money inserted by the user

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!