If the price entered is negative print an error message and


Your program must meet the following specifications:

At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies. Repeatedly prompt the user for a price in the form xx middot xx, where x denotes a digit, or to enter 'q' to quit.

When a price is entered:

a. If the price entered is negative, print an error message and start over requesting either a new-price or to quit (indicated by entering a 'q').

b. Prompt for the number of dollars in payment. If the payment is insufficient, print an error message and reprompt for payment.

c. Next determine the coins to be dispensed as change. This calculation will depend on the amount to be dispensed and also on the number of coins left in the stock.

For example, the least number of coins needed to make change of $1.30 is 6: 5 quarters and I nickel. But if there are only 3 quarters, 3 dimes, and 10 nickels left in the stock, then the least number is 11: 3 quarters, 3 dimes, and 5 nickels.

d. Print the numbers of the coins to be dispensed as change and their denominations. (Omit a denomination if no coins of that denomination will be dispensed.)

e. In case exact payment is made, print a message such as "No change."

f. If the change cannot be made up with the coins remaining, print an error message and halt the program Just before quitting, print the total amount (the number of dollars and number of cents) left in the stock.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: If the price entered is negative print an error message and
Reference No:- TGS02900731

Expected delivery within 24 Hours