Question

Module 6 - Cash Register (10 Points) We are going to write a program that simulates a customers transaction at a cash regist1 import sys # Global Variables and Functions Should Be Defined Below 6 7 8. # We Give You Starter Code for Your User Menu is

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Run code in python 3

And if you need any more info, comment me

import sys

order_total = 0.00


def add():
    """
    prompt the user to add amount
    :return:
    """
    add_amount = float(input("please add the amount to order: "))
    global order_total
    order_total += add_amount
    return add_amount


def clear():
    """
    clear total amount
    :return:
    """
    global order_total
    order_total = 0
    print(order_total)


def calcchange():
    """
    calculate change the amount
    :return:
    """
    global order_total
    cents = order_total*100+0.01
    dollars = int(cents /100)
    cents = cents %100
    quarters = int(cents/25)
    cents = cents %25
    dimes = int(cents/10)
    cents = cents %10
    nickels = int(cents/5)
    cents = cents %5
    pennies = int(cents)
    print("total Amaount", round(order_total, 2), "\n", dollars, "dollars", quarters,
          "quarters", dimes, "dimes", nickels, "nickels", pennies, "pennies")
    return order_total, dollars, quarters, dimes, nickels, pennies


isOrderDone = False
while (isOrderDone==False):
    print()
    userChoice = input("What would you like to do? "
                       "Enter A to add an item, C to clear this order, X to check out, or Q to quit.")
    # userChoice.upper() Accept lower case also 
    if (userChoice.upper() == "A"):
        add()
    elif (userChoice.upper() == "C"):
        clear()
    elif (userChoice.upper() == "X"):
        calcchange()
    elif (userChoice.upper() == "Q"):
        sys.exit(0)
    else:
        print("Invalid option entered, please try again")

the output is given below

What would you like to do? Enter A to add an item, C to clear this order, X to check out, or Q to quit.a
please add the amount to order: 45.36

What would you like to do? Enter A to add an item, C to clear this order, X to check out, or Q to quit.a
please add the amount to order: 78.42

What would you like to do? Enter A to add an item, C to clear this order, X to check out, or Q to quit.x

Total amount 123.78
 123 dollars 3 quarters 0 dimes 0 nickels 3 pennies

What would you like to do? Enter A to add an item, C to clear this order, X to check out, or Q to quit.c

What would you like to do? Enter A to add an item, C to clear this order, X to check out, or Q to quit.x
Total amount 0
0 dollars 0 quarters 0 dimes 0 nickels 0 pennies

What would you like to do? Enter A to add an item, C to clear this order, X to check out, or Q to quit.q

C:\Users\sameer\PycharmProjects\untitled\application>

Add a comment
Know the answer?
Add Answer to:
Module 6 - Cash Register (10 Points) We are going to write a program that simulates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Use python to code! Q1 - You need to keep track of book titles. Write code...

    Use python to code! Q1 - You need to keep track of book titles. Write code using function(s) that will allow the user to do the following. 1. Add book titles to the list. 2. Delete book titles anywhere in the list by value. 3. Delete a book by position. Note: if you wish to display the booklist as a vertical number booklist , that is ok (that is also a hint) 4. Insert book titles anywhere in the list....

  • I'm getting this error message, and trying to figure out why. Check 1 failed Output: What...

    I'm getting this error message, and trying to figure out why. Check 1 failed Output: What would you like to do? Expected: What would you like to do? Thank you for banking with us. ATM Summary Your final function in the ATM Script is the Print the Customer summary as follows: Final Input userchoice = input ("What would you like to do?\n") userchoice = 'Q' Final Output What would you like to do? Thank you for banking with us. ATM...

  • Please help me to do my assignment it should be python. Thank you Write a menu-driven...

    Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • Language: C# In this assignment we are going to convert weight and height. So, the user...

    Language: C# In this assignment we are going to convert weight and height. So, the user will have the ability to convert either weight or height and as many times as they want. There conversions will only be one way. By that I mean that you will only convert Pounds to Kilograms and Feet and Inches to Centimeters. NOT the other direction (i.e. to Pounds). There will be 3 options that do the conversion, one for each type of loop....

  • Calculate the Balance - Withdrawal If the action is Withdrawal ‘W’, use the withdrawal function to...

    Calculate the Balance - Withdrawal If the action is Withdrawal ‘W’, use the withdrawal function to remove funds from the account Hint – The formatter for a float value in Python is %f. With the formatter %.2f, you format the float to have 2 decimal places. For example: print("Account balance: $%.2f" % account_balance) Withdrawal Information Withdraw Input userchoice = input ("What would you like to do?\n") userchoice = 'W' withdrawal_amount = 100 Withdraw Output What would you like to do?...

  • Please design, write the code and create the requisite submission files in C++ for the following...

    Please design, write the code and create the requisite submission files in C++ for the following problem: A menu-driven program that offers the user 5 options as follows: Menu: 1. Display array 2. Add up all elements in the array and display that number. 3. Add 1 to each element in the array. 4. Swap the values in row one with the values in row three. 5. Exit In main(), declare and initialize a 2-dimensional array that contains 5 x...

  • Write a C++ program to manage a list of students waiting to register for a course...

    Write a C++ program to manage a list of students waiting to register for a course using a linked list. Operations should include adding a new student at the end of the list, adding a new student at the beginning of the list, removing a student from the beginning of the list, removing a student from the end of the list, and removing a student by name. Allow the user an option to exit. NOTE: Functions/Methods must used throughout program....

  • You are going to write an object that takes a word (or short phrase) as an...

    You are going to write an object that takes a word (or short phrase) as an input for the Constructor and then will reverse the letters in the word. The object to implement this is referred to as **ReverseWord** and consists of **only** the following public methods: **public void setWord(String word)** - Sets the word to be processed. **public String getWord()** - Returns the word that is set with **setWord**. Note that if this is called before setWord then an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT