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

image text in transcribedimage text in transcribed

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.c., 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 S20 notes, then $10, and finally by the S5 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 'O'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 'O' 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. Denomination Accumulation 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 'O' upon which the program would invoke a function called "Print TotalDenom" 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, '15':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 o 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 : No. of $50 bills : No. of $20 bills: No. of $10 bills : No. of $5 bills : 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

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions