Answered step by step
Verified Expert Solution
Link Copied!

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. 15 cents for Hersheys Kisses, 25 cents for Reeses Peanut Butter Cups, or 50 cents for snickers. Write a C program that accepts coins from the user, it accepts quarters (25 cents), dimes (10 cents), and nickels (5 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 0,5,10, or 25.
-Use macro definitions to define constants for the amount of each candy
-Follow the format of the examples below.
Example 1
Insert coins: 10
Insert coins: 10
Insert coins: 0
1 Hersheys kisses (15 cents),2 Reeses Peanut Butter Cups (25 cents),3- Snickers (50 cents)
Enter your choice: 2
Insufficient amount, 20 cents returned
Example 2
Insert coins: 10
Insert coins: 10
Insert coins: 0
1 Hersheys kisses (15 cents),2 Reeses Peanut Butter Cups (25 cents),3- Snickers (50 cents)
Enter your choice: 1
Your change is 5 cents
Example 3
Insert coins: 10
Insert coins: 10
Insert coins: 0
1 Hersheys kisses (15 cents),2 Reeses Peanut Butter Cups (25 cents),3- Snickers (50 cents)
Enter your choice: 4
Invalid selection, 20 cents returned

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

Students also viewed these Databases questions