Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

You are tasked with creating a text-based program for simulating a supermarket self-service checkout using the Python 3 programming language. The assignment is broken up into four main components: 1.)...

1 answer below »
You are tasked with creating a text-based program for simulating a supermarket self-service checkout using the Python 3 programming language. The assignment is broken up into four main components: 1.) Design and model two classes: Product and CheckoutRegister, 2.) Create an activity chart which describes the behaviour of the checkout system, 3.) Create a computer program that allows a user to interactively check out a number of products, then provides an opportunity to enter some virtual money to pay for the products and finally and prints out a receipt for the user (to the screen, not on paper), and finally 4.) Explain and integrate some code into your checkout program that places the products purchased into virtual shopping bags. Your submission should consist of one Microsoft Word or LibreOffice document containing the first two parts of the assignment, and three Python scripts that implement the computer program (checkoutregister.py, product.py and main.py). The main.py script runs the main logic of the program and will use instances of the CheckoutRegister and Product classes to simulate checking out of the supermarket. You are provided with a Microsoft Word template to help you complete the first two parts of this assignment. Towards the end of this document you will also be provided with the output of a simulated run of the completed computer program which may help you with this assignment.
Answered Same Day May 08, 2020 ITECH1400

Solution

Abr Writing answered on May 09 2020
136 Votes
Supermarket Self-Service Checkout.html


In [1]:

%run main.py
----- Welcome to FedUni checkout! -----
Please enter the barcode of the product: 123
Milk 2.0
Would you like to scan another product? (Y/N)y
Please enter the barcode of the product: 456
Coffee 3.0
Would you like to scan another product? (Y/N)y
Please enter the barcode of the product: 999
This product does not exist in our inventory.
Would you like to scan another product? (Y/N)n
Payment due: 5.0
Please enter an amount to pay: 1
5.0
1.0
Payment due: 4.0
Please enter an amount to pay: -3
We don't accept negative money!
Please enter an amount to pay: 5
4.0
5.0
----- Final Receipt -----
Milk 2.0
Coffee 3.0
Total amount due: 5.0
Amount received: 6.0
Change given: 1.0
Thank you for shopping at FedUni!
(N)ext customer, or (Q)uit?q
main.py
from CheckoutRegister import CheckoutRegiste
# If the final option of (N)ext customer is chosen, the program runs again
moreCustomer = True
while moreCustomer:
    print('----- Welcome to FedUni checkout! -----')
    register = CheckoutRegister()
    #
    while True:
        # Taking user input: barcode of the product
        barcode = float(input('Please enter the barcode of the product: '))
        # Scanning the product using the function scan_item
        register.scan_item(barcode)
        # Taking user input: More products or not?
        prod = input('Would you like to scan another product? (Y/N)')
        # Taking decision based on customer's input
        if prod.lower() == "n":
            # Calculating the amount due by the custome
            register.due()
            due = 0
            for idx in register.itemList:
                due += register.product.price[idx]
            print('Payment due: ', register.total)
            total = register.total
            #
            while True:
                tmp = register.accept_payment(float(input('Please enter an amount to pay: ')))
                if tmp == "negative"    :
                    continue
                print(total)
                print(register.pay[-1])
                if total > register.pay[-1]:
                    print('Payment due: ', total - register.pay[-1])
                    total = total - register.pay[-1]
                else:
                    
eak
            
            # Printing the receipt
            register.print_receipt()            
            
eak
        else:
            continue
            
    # Taking user input: More customers?
    next = input('(N)ext customer, or (Q)uit?')    
    if next.lower == 'n':
        continue
    else:
        moreCustomer = False
Product.py
import pandas as pd
class Product:
    def __init__(self):
        fileName = 'products.csv'
        # reading product data from fileName (.CSV file)
        df = pd.read_csv(fileName)
        self.barcode = list(df.barcode)
        self.name = list(df.name)
        self.price = list(df.price)
products.csv
arcode,name,price
123,Milk,2
212,Bread,3
456,Coffee,3
923,Sugar,5.5
Supermarket Self-Service Checkout.ipyn
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"----- Welcome to FedUni checkout! -----\n",
"Please enter the barcode of the product: 123\n",
"Milk 2.0\n",
"Would you like to scan another product? (Y/N)y\n",
"Please enter the barcode of the product: 456\n",
"Coffee 3.0\n",
"Would you like to scan another product? (Y/N)y\n",
"Please enter the barcode of the product: 999\n",
"This product does not exist in our inventory.\n",
"Would you like to scan another product? (Y/N)n\n",
"Payment due: 5.0\n",
"Please enter an amount to pay: 1\n",
"5.0\n",
"1.0\n",
"Payment due: 4.0\n",
"Please enter an amount to pay: -3\n",
"We don't accept negative money!\n",
"Please enter an amount to pay: 5\n",
"4.0\n",
"5.0\n",
"----- Final Receipt ----- \n",
"Milk 2.0\n",
"Coffee...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here