Comp 115 Programming Assignment 03: Candy Machine

Due 11:59pm Thursday, March 26 2020

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.

The Problem

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.

Input

The program should ask the user for the following input (in the same order as they are shown here):

  1. The type of candy, selected using a single letter from a menu (see specifics below)
  2. How many ounces of candy the user wishes to buy (a float)
  3. Whether the user wants to pay cash ($) or credit (c)
  4. If the user decided to pay cash, the amount of money the user will enter (a float).
Output

Before the user enters anything, the program should print a menu offering the following options:

The menu should describe each option, its price and which character to enter to select it.

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.

Specifics
In addition, your program should use the following functions: All these functions should be used by your main program, so that the main function will mostly just serve as the user interface and its code is kept somewhat short and simple.

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)