Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program that simulate a cash register for a commercial shop. Assume that the business of this shop is run in a special

Write a Python program that simulate a cash register for a commercial shop. Assume that the business of this shop is run in a special way as follows:

  • It sells goods of $5 dollars multiples, i.e., all goods are priced 5, 10, 15, etc all princes are prices that can be divided by five evenly.
  • The customers have to pay for their purchased goods cash. The cash they pay have to be of exact number of notes that are needed to cover their bills. The denominations used to pay the bill should starting by the $100 notes, then $50 notes, then $20 notes, then $10, and finally by the $5 notes. For example: For a bill amount of $375, the customer must pay: 1) three notes of $100, 2) one note of $50, 3) one note of $20, and 4) one note of $5.

The program should ask the user to enter the amount of the bill to be paid for his/her purchases. The program should loop indefinitely to collect bills until the user Enter 0 zero, only then the program prints on the screen the number of notes of each denomination that should be in the cash register. Then the program comes to halt.

The program should have in addition to the main() function the following functions:

  1. Bill function: to collect a bill amount from the user or 0 to print the total and quit. This function returns the entered bill amount or 0.
  2. Denomination function: It takes as an input the bill amount returned by function 1 above, then this function returns the correct number of notes as described above.
  3. DenominationAccumulation function: It takes as an input the number of notes returned from the function 2 above, then this function adds those denomination notes to accumulated notes already collected in the cash register.
  4. As explained above, the program should loop indefinitely collecting bills, break them down to proper number of denominations, and calculate the accumulated number of notes of all denominations. The program should keep on doing that until the user enters 0 upon which the program would invoke a function called PrintTotalDenom that would print the total number of notes of each denomination.

All the above 4 functions should be called and dealt with from within (inside) the main function, but written outside the main function, of course. Also, the main function should start with the following:

global acDen

acDen={'h100':0,'f50':0,'t20':0,'t10':0,'f5':0}

In the first line we declare a global variable call acDen (Stands for accumulated denominations).

In the second line we create a dictionary that define the accumulated denominations to zeros as a start.

Below is an example of how the program runs:

Enter a bill amount

or 0 Zero to get the

total denominations : 250

Enter a bill amount

or 0 Zero to get the

total denominations : 175

Enter a bill amount

or 0 Zero to get the

total denominations : 10

Enter a bill amount

or 0 Zero to get the

total denominations : 0

No. of $100 bills : 3

No. of $50 bills : 2

No. of $20 bills : 1

No. of $10 bills : 1

No. of $5 bills : 1

Note: the above run of the program is an example. The program should be able to work with random amount of bills as an input and should print the correct number of notes according to the entered bills.

The program should use the exact names suggested above for the functions and the denominations. And the program should produce the same text used in the example above. Notice the spaces and insert the proper newlines as illustrated in the example.

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

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions