Write a program that calculates the amount of change to be returned from a vending machine using Harry Potter currency.

Assignment 3 – Vending Machine

Write a program that calculates the amount of change to be returned from a vending machine using Harry Potter currency. In the wizarding world of Harry Potter, the currency system is not based off dollars and cents, but instead 3 different coins: knuts, sickles, and galleons. The conversion values for these coins in knuts are as follows:
1 knut = 1 knut
1 sickle = 29 knuts
1 galleon = 493 knuts

The knut is similar to a cent (or penny) in U.S. currency, and the sickle is similar to a U.S. quarter. One dollar equals 4 quarters or 100 cents. In Harry Potter currency, one galleon equals 17 sickles or 493 knuts.
The vending machine dispenses 4 options: Assortment of candy for 11 sickles and 7 knuts, Butterbeer for 2 sickles, Daily Prophet for 5 knuts, and Quill for 6 sickles.
The vending machine accepts galleons, sickles, and knuts for payment.

Steps
In PyCharm (Community Edition), open your existing ITP115 project.
Under the Assignments directory, create a new directory called a3_last_first where last is your last/family name and first is your preferred first name. Use all lowercase letters.
In the directory, create a new Python file called assignment3.py.

At the top of the file, put comments in the following format and replace the name, email, and section with your actual information:
This content is protected and may not be shared, uploaded, or distributed.

Describe what this program does such as:
This program creates a Harry Potter vending machine.
User enters payment and the program determines the change.
Display the following to the user:

Select an item from the vending machine:
a) Assortment of Candy for 11 sickles and 7 knuts
b) Butterbeer for 2 sickles
c) Quill for 6 sickles
d) Daily Prophet for 5 knuts
Get input from the user for their menu choice using the following prompt:

Choice: b

Your code must handle the user entering upper case and lower case letters. For example, the user can enter b or B to select a Butterbeer. Create some variables to hold the item (string) and the cost (int). The user input is shown in green.

Your code must handle the user entering an invalid menu choice. If the user enters something other than the choices on the menu, then tell them they have entered an invalid option. Since we have not covered how to repeat code yet, just pick an option for them.

10.Calculate the cost of the item in knuts and put that into a variable. Calculate the payment in knuts and put that into a variable. Print out the cost and the payment.

11.If the payment is less than the cost, then print a message to the user saying that the user will not receive their item.

12.If the payment is enough, then calculate the change in knuts. Print the item and the change in knuts. Using the division and modulo operators, calculate the change that will be dispensed in galleons, sickles, and knuts. Print the number of each coin for the change. Feel free to create variables to hold information.
You must dispense change in the largest possible coins.

13.Be sure to comment your code. This means that there should be comments throughout your code. Generally, a comment for every section of code explaining what it does. Points will be deducted for not having comments.

14.Follow coding conventions.

15.Test the program. Look at the Sample Output below. Assignments that do not run are subject to 20% penalty.

16.Prepare your submission:
Find the a3_last_first folder on your computer and compress it. This cannot be
done within PyCharm.
On Windows, use File Explorer to select the folder. Right click and select the Send to -> Compressed (zipped) folder option. This will create a zip file.
On Mac OS, use Finder to select the folder. Right click and select the Compress “FolderName” option. This will create a zip file.

17.Upload the zip file to your Blackboard section:
On Blackboard, navigate to the appropriate item.
Click on the specific item for this assignment.
Click on the Browse Local Files button and select the file. o Click the Submit button.

Write a program that calculates the amount of change to be returned from a vending machine using Harry Potter currency.
Scroll to top