Question: 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
Get step-by-step solutions from verified subject matter experts
