Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program that computes the correct change to return to a customer using cash to pay for snacks and soft drinks from a
Write a C program that computes the correct change to return to a customer using cash to pay for snacks and soft drinks from a vending machine. Coins in 50 cents, 1 dollar, 2 dollars, 5 dollars, and 10 dollars denominations are available. The number of coins to be returned to the customer should be minimized. . First, let the program display the amount that the customer has to pay. Here, let the program choose an amount from {$0.50, $1.00, $1.50, ..., $19.50, $20.00} at random. Next, let the program take as input the amount of cash that the customer inserted into the vending machine. Finally, let the program display the number of 50-cent, 1-dollar, 2-dollar, 5-dollar, and 10- dollar coins to be returned to the customer. In case the amount paid by the customer is not enough then the program should give an error message. As an example, if the cost is $5.50 and the customer pays $10 then the change should consist of one 50-cent coin and two 2-dollar coins. (4 marks)
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