Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Welcome to Vend-O-Matic HERE ARE THE SELECTIONS: P - Potato Chips $1.25 C - Choc

ID: 3617759 • Letter: W

Question

Welcome to Vend-O-Matic

HERE ARE THE SELECTIONS:

P - Potato Chips                   $1.25

C - Chocolate bar                $1.30

B - Brownie                           $1.75

N - Nuts                $1.40

K - Keebler crackers           $1.00

O - Oreo cookies                  $1.50

Please enter a selection: k

Please deposit your money by selection:

     1-$5.00

     2-$1.00

     3-$0.25

     4-$0.10

     5-$0.05

Deposit Amount: 1

------------------------------

Price of Item: k is $1.00

Balance Entered: $5.00

DISPENSING SELCTION: k

DISPENSING CHANGE: 4.00

#define

#include

//Function prototype

// Displays the list of snack items and prompts for the users choice

void

//sets the cost of the purchase based on value in selection

void

//uses CoinMenu function to display and collect money from the user

//uses CheckMoney function to keep comparing the deposited amount to the item cost.

void

//Displays the codes for coin input gets user input amounts

//compares the int codes and updates the purchase amount entered

void

//compares the amount the user has deposited to the price of item selected.

//returns 1 if the amount is enough to cover the cost, 0 if there is not enough.

int

//Asks the user if they want another snack.

void

int

{

printf(

Menu(&selection);

printf(

GetCost(selection,&item_cost);

printf(

GetMoney(&purchase, item_cost, selection);

Quit(&again);

printf(

}

Explanation / Answer

please rate - thanks gets you a little further #define _CRT_SECURE_NO_DEPRECATE #include //Function prototype // Displays the list of snack items and prompts for the userschoice void Menu(char *selection); //sets the cost of the purchase based on value in selection void GetCost(char selection, double *item_cost); //uses CoinMenu function to display and collect money from theuser //uses CheckMoney function to keep comparing the deposited amountto the item cost. void GetMoney(double *purchase, double item_cost, charselection); //Displays the codes for coin input gets user input amounts //compares the int codes and updates the purchase amountentered int CoinMenu(); //compares the amount the user has deposited to the price of itemselected. //returns 1 if the amount is enough to cover the cost, 0 if thereis not enough. double CheckMoney(int); //Asks the user if they want another snack. void Quit(char *again); int main ( ) { char selection; char again =' '; double item_cost; double purchase; printf("Welcome to Vend-O-Matic "); do{ //menu function displays snakcs and gets snack choice Menu(&selection); printf(" The menu selection is %c ", selection); //sets the cost of the purchase based on value in selection GetCost(selection,&item_cost); printf(" Item cost is %.2f ", item_cost); //uses CoinMenu function to display and collect money from theuser //uses CheckMoney function to keep comparing the deposited amountto the item cost. GetMoney(&purchase, item_cost, selection); //yes or no to quit choice Quit(&again); printf(" choice entered %c ", again); }while(again!='n'&& again!='N'); printf (" GODDBYE "); } //Function Definitions //Asks the user if they want another snack. void Quit(char *again) { //char selection; printf(" Do you want another snack (y or n): "); scanf(" %c", again); //return selection; } // Displays the list of snack items and prompts for the userschoice void Menu(char *selection) { printf(" P Potato Chips $1.25 "); printf("C Chocolate bar $1.30 "); printf("B Brownie $1.75 "); printf("N Nuts $1.40 "); printf("K Keebler crackers $1.00 "); printf("O Oreo cookies $1.50 "); scanf(" %c", selection); } //sets the cost of the purchase based on value in selection void GetCost(char selection, double *item_cost) { //if selection is c *item_costPtr is 1.30 if(selection == 'p' || selection == 'P') { *item_cost= 1.25; } else if(selection == 'c' || selection == 'C') { *item_cost= 1.30; } else if(selection == 'b' || selection == 'B') { *item_cost= 1.75; } else if(selection == 'n' || selection == 'N') { *item_cost= 1.40; } else if(selection == 'k' || selection == 'K') { *item_cost= 1.00; } else if(selection == 'o' || selection == 'O') { *item_cost= 1.50; } } //uses CoinMenu function to display and collect money from theuser //uses CheckMoney function to keep comparing the deposited amountto the item cost. void GetMoney(double *purchase, double item_cost, charselection) {int amt; double paid=0; //*purchase while(paid
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote

Navigate



Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.