Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The programming language is C++ Problem Statement Let's assume that we will not be using credit cards or mobile payment apps. Cash only. Grocery stores

The programming language is C++
Problem Statement

Let's assume that we will not be using credit cards or mobile payment apps. Cash only. Grocery stores now often have a "U-Scan" checkout lane, allowing the customer to scan and check out their own groceries, without the need of a human checker. These lanes require that change be provided automatically, after the customer sticks their cash in a slot. You are to write a program that computes the bills and coins to be dispensed, minimizing the total number of bills and coins. (That is, for change totaling $5.50, you should not dispense 5 ones and 50 pennies, but a $5 bill and a 50-cent piece instead.)

The bills and coins available for you to dispense are as follows: $100 bill, $50 bill, $20 bill, $10 bill, $5 bill, $1 bill, 50-cent coin, 25-cent coin, 10-cent coin, 5-cent coin, 1-cent coin.

The console-based program, which can easily be converted to an internet program with GUI at some future date, prompts the user to input 2 numbers. The first number is the amount of the purchase, and the second one is the amount tendered by the customer. You may assume that the amount tendered is greater than or equal to the amount of purchase. The console output will be a series of lines showing the amount of change returned and detailing the number of bills and coins that will be dispensed as change, in descending order of monetary amount, one unit per line. If a bill/coin is not needed in the change returned, no output is produced for that bill/coin. (In other words, do not display "0 $1 bills".)

Plural logic. Proper use of plurals is required, as shown in the sample below. This will require some if-else logic to decide whether or not to append an "s" to the end of a denomination name.

Here the sample -- for a purchase of 42.15, the amount tendered is 50. There are no $'s or commas in the input -- just positive real numbers that may or may not contain a decimal. Here is the output:

$7.85 1 $5 bill 2 $1 bills 1 50-cent coin 1 25-cent coin 1 10-cent coin

The program ends normally after the output is produced.

This problem is not as easy as it seems. Be aware of the effects of round-off error, and remember not to test floating point values for exact equality. Remember that with floating point values and computers, 4 minus 2 can often result in 1.9999999999999999 instead of 2, and that is not greater or equal to 2!

Cashiers solve this problem every day, without using division and dealing with remainders. So your program should be able to solve it too, without divide or modulus and without cmath. Think about it -- it's not hard. Solve it using loops.

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions