Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use exact wording as shown above, thank you! Assignment Overview This assignment will give you more experience on the use of 1. integers (int)

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Please use exact wording as shown above, thank you!
Assignment Overview This assignment will give you more experience on the use of 1. integers (int) 2. floats (float) 3. conditionals 4. iteration Your program will calculate change. It will start with a stock of coins. It will then repeatedly request the price for an item to be purchased or to quit. If a price is input, it will prompt for dollars in payment and print the change due using the minimum number of coins possible. Before quitting, it will display the value of coins remaining in the stock. A of this description. n example interaction with our program appears at the end Background The algorithm for calculating the numbers of coins of each denomination to dispense so as to minimize the total number of coins is an example of a greedy algorithm. You start by figuring out the most number of quarters you can dispense (without exceeding the amount), then the most number of dimes, then the number of nickels and finally pennics. If you are curious, you can read about the Greedy Algorithm Project Description/Specification Your program must meet the following specifications: . At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies. 2. Repeatedly prompt the user for a price in the form xx.xx, where x denotes a digit, or to enter 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 3. 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 crror 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 1 nicke. But if there are only 3 quarters, 3 dimes, and 10 nickels left in the stock, then the least number is I1: 3 quarters, 3 dimes, and 5 nickels. 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) d. c. In case exact payment is made, print a message such as "No change

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

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

Name the parts that comprise the knee joint.

Answered: 1 week ago

Question

Answer using the table. Look at both pictures.

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago