IASP 505 MU Programming Items Purchased at Different Cities Project

Recall the hands-on practice covered in class. This assignment is to read a basket file that
contains items purchased at different cities. Your code computes taxes for those items and
provides a couple of different ways, e.g., on the cashier’s monitor and on the receipt. See the
code provided below. Make sure your Python code runs in the same way that is shown in the
sample run below.
—– beginning of the code —–
path = input(“Enter the fully qualified path expression to the file name: “)
fp = open(path)
# The data type: its format should be the same; however its contents may vary!
# The data is case-sensitive and should be compatible with the basket data
product = {“Windows Laptop”: 1000.0, “Mac Laptop”: 1800.0, “mouse”: 50.9,
“keyboard”: 75.1, “monitor”: 200.0, “shirt”: 9.99, “shoes”: 99.9}
salesTax = {“MT”: .1, “White Plains”: .09, “Queens”: .085}
# this function is the same as in the hands-on practice
def priceIncludingSalesTax (item, city):
price = product[item]
taxRate = salesTax[city]
total = price * (1+taxRate)
return total
# checkout() function should call priceIncludingSalesTax()
# subtotal for each city is displayed
# at last, the grandtotal is displayed
# checkout() returns a dictionary, e.g., {‘MT’: 120.87900000000002, ‘White Plains’: 1389.859,
‘Queens’: 55.226499999999994}
def checkout(bk):
checkout = {}
grandTotal = 0.0
for each in bk:
# your code here
for e in rest:
# your code here
print(“Subtotal from {} is ${:.2f}”.format(city, subTotal))
grandTotal += subTotal
checkout[city] = subTotal
print(“The grand total is ${:.2f}”.format(grandTotal))
return checkout
# read2basket() function takes the file pointer, fp
# construct a basket which is a list of lists, e.g., [[‘MT’, ‘ shirt’, ‘ shoes\n’], [‘White Plains’, ‘
Windows Laptop\n’], [‘Queens’, ‘ mouse\n’]]
# read2basket() returns the basket
def read2basket(fp):
basket = []
for line in fp:
# your code here
return(basket)
# prettyprint() function prints the basket and receipt in a pretty format
# for each city, each item purchased is shown its tag price, tax and price including the tax
# for each city, a subtotal is displayed
# Finally, the total amount paid is displayed.
# prettyprint() does not return any data
def prettyprint(b, r):
print(“=”*20, “receipt”, ‘=’*20)
total = 0.0
for each in b:
# your code here
for item in items:
# your code here
print(“\t{:20} {:.2f} {:5} {:.2f} {:5} {:.2f}”.format(item,
price, ” “, tax, ” “, price+tax))
sum = r[city]
print(“\t{:30} {:.2f}”.format(“——- subtotal ——-“, sum))
total += sum
print(“\n{:30} ${:.2f}”.format(“=-=-=-=-=-=-=-=-= GRAND total =-=-=-=-=-==-=-=”,total))
print(“\n\n\n”, “=”*13, “the end of the receipt”, ‘=’*13)
# caller should be the following – no change the following code!!!
basket = read2basket(fp)
print(basket)
receipt = checkout(basket)
print(receipt)
prettyprint(basket, receipt)
— end of the code –Please be advised that the methods associated with a string called .strip() or .replace(“\n”, “”)
may be needed,
Sample basket in a file: each line begins with a city followed by items purchased
MT, shirt, shoes
White Plains, Windows Laptop, keyboard, monitor
Queens, mouse
Sample run:
Enter the fully qualified path expression to the file name: /Users/jyoon/JohnsBackup/Mercy/505foundaCSEC/inClass/f23/basket.data
[[‘MT’, ‘ shirt’, ‘ shoes\n’], [‘White Plains’, ‘ Windows Laptop’, ‘ keyboard’, ‘
monitor\n’], [‘Queens’, ‘ mouse\n’]]
Subtotal from MT is $120.88
Subtotal from White Plains is $1389.86
Subtotal from Queens is $55.23
The grand total is $1565.96
{‘MT’: 120.87900000000002, ‘White Plains’: 1389.859, ‘Queens’: 55.226499999999994}
==================== receipt ====================
@ MT ——->
shirt
9.99
1.00
10.99
shoes
99.90
9.99
109.89
——- subtotal ——120.88
@ White Plains ——->
Windows Laptop
1000.00
90.00
1090.00
keyboard
75.10
6.76
81.86
monitor
200.00
18.00
218.00
——- subtotal ——1389.86
@ Queens ——->
mouse
50.90
4.33
55.23
——- subtotal ——55.23
=-=-=-=-=-=-=-=-= GRAND total =-=-=-=-=-=-=-=-= $1565.96
============= the end of the receipt =============
For your understanding, the purple highlights are on the cashier’s monitor, while the yellow
highlights are on the customer’s receipt.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER