You are required to work on this lab in teams of two. You must complete this lab with your teammate only, although you may discuss lab concepts with other students. Please keep the Academic Integrity Policy in mind---do not show your code to anyone outside of the professors and tutors, and do not look at anyone else's code for this lab. If you need help with the assignment or have trouble finding a teammate, please post a question/request on Piazza, or contact the professor.
In this project, you will practice computing with numbers. I kept it reasonably short, and you should be able to complete it using only input, output and mathematical operations. Save your code in a file whose name consists of the first letter of your first name followed by your last name and Prg3. For example, if I submitted an assignment, I would name the file mgagnePrg3.py.
Weston College wants to install a candy machine that sells candy in bulk. They already have the robot that will measure orders, they want you to write the program that will display the price of candy and count change.
The program should ask the user for the following input (in the same order as they are shown here):
Before the user enters anything, the program should print a menu offering the following options:
r
)a
)c
)After the user entered all their input, the program should display a receipt for the transaction that looks similar to the following (it does not have to be exactly the same, but the information should be present and in the same order):
1.5 ounces of Chocolate covered raisins ......... $0.90 Cash discount (3%) .............................. $0.03 Tax (4%) ........................................ $0.03 Total: .......................................... $0.90 Amount given: ................................... $1.00 Change: ......................................... $0.10
For the purpose of printing the receipt, you can assume that the weight of the order will not have more than one decimal, and that the order should not have more than 100 ounces. All the amounts should be right aligned and displayed in a nice column.
If the customer pays credit, the line about the cash discount should not be displayed, the amount given should be the same as the total and there should be no line for the change.
IMPORTANT NOTE: if the code entered from the menu is invalid, or the user enters an invalid symbol for the payment (not $ or c), the program should just print an error message and terminate, no receipt should be printed.
round
function that is already defined in Python, let's not worry about its occasional strange behavior. You can read its description in the Python Documentation to figure out how to round to 2 decimals. Do not rely on output formatting to do the rounding, the formatting does not modify the value of variables, it only makes the displayed amount look pretty.printMenu
that, well, prints the menu. The function should not take any input parameters, and it does not return anything.calculateDiscount
that takes a number (an amount of money) as input parameter and calculates the 3% cash discount on that amount. The discount should be returned by the function.calculateTax
that takes a number (an amount of money) as input parameter and calculate the 4% tax on that amount. The amount of tax should be returned by the function.As usual, at the top of your file, you should have a header describing the usual information, and the program should follow the usual template described in class (and shown here)