Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* * * CODE IN C * * * A candy vending machine sells a few popular candies. 1 5 cents for Hershey s Kisses,
CODE IN C
A candy vending machine sells a few popular candies. cents for Hersheys Kisses, cents for Reeses Peanut Butter Cups, or cents for snickers. Write a C program that accepts coins from the user, it accepts quarters cents dimes cents and nickels cents User will enter enters zero to stop input. Then give the user a choice for the candy selection. If the amount is sufficient, print a message and calculate the change. If the amount is not sufficient, display a message for insufficient amount and return the money.
Assume the input will be only or
Use macro definitions to define constants for the amount of each candy
Follow the format of the examples below.
Example
Insert coins:
Insert coins:
Insert coins:
Hersheys kisses cents Reeses Peanut Butter Cups cents Snickers cents
Enter your choice:
Insufficient amount, cents returned
Example
Insert coins:
Insert coins:
Insert coins:
Hersheys kisses cents Reeses Peanut Butter Cups cents Snickers cents
Enter your choice:
Your change is cents
Example
Insert coins:
Insert coins:
Insert coins:
Hersheys kisses cents Reeses Peanut Butter Cups cents Snickers cents
Enter your choice:
Invalid selection, cents returned
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started