Question

Modify your code from the previous part so that once the customer finishes selection from the...

Modify your code from the previous part so that once the customer finishes selection from the menu and sees the receipt, they are presented with one final menu. This menu should allow the customer to select the pay options. Their choices should be:

(a) Cash

(b) One time pay card

Again, the user should make their selection by entering the corresponding number, and bad selections should cause the menu to repeat. If customer chooses ‘Cash’ it should print that payment is completed and program should terminate. If the choice is ‘One time pay card’ then your program asks for 4-digit card number and displays the invoice as follows (see the sample output) and terminates.

Note:

To display the sample 4-digit number 2345 as ‘xx45’ you must not use any string processing functions. Instead, you should use arithmetic operators that we covered in class.

Sample output:

… it first prints similar content as shown before and then ……

How would you like to pay? Select one from the following menu.

(a) Cash

(b) Prepaid Card

> a

Thank you for your payment. Have a nice day!

Sample output:

… it first prints similar content as shown before and then ……

How would you like to pay? Select one from the following menu.

(a) Cash

(b) Prepaid Card

> b

Enter 4 digit card number: 2345

You have paid by xx45. Have a nice day!

Some considerations:

• Your output should be neatly formatted.

• You cannot assume the user enters good input. That is, they may enter non-integer values and integer values outside the acceptable range. Your program must handle these issues by printing an appropriate error message and repeating the menu until a proper value is entered.

use python

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

#Python program that prompts user to enter a choice of menu
#If user selects a then the print a message
#if user select b then prompt user for 4 digit number
#then find display message as shown in input.
def main():

#call menu function
choice=menu()
#check if choice is a
if choice=='a':
print('Thank you for your payment. Have a nice day!')
#check if choice is b
elif choice=='b':
repeat=True
#repeat till user enter a valid integer type input
while repeat:
try:
cardNum = int(input('Enter 4 digit card number:'))
repeat=False
except :
print('Invalid input.')
print('You have paid by xx%d .Have a nice day!'%(cardNum%100))
else:
print('Invalid choice')

#Function that display a menu of choices
#then prompt user to enter his choice
def menu():
print('How would you like to pay? Select one from the following menu.')
print('(a) Cash')
print('(b) Prepaid Card')
#read choice
choice=input('>')
return choice
#call main function
if __name__ == '__main__':
main()

Sample Output:

Add a comment
Know the answer?
Add Answer to:
Modify your code from the previous part so that once the customer finishes selection from the...
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 code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • Programming Fundamental (C++) Lab C++ Lab Ra'fat Amareh Faculty of Engineering and Information Technology Assignment Write...

    Programming Fundamental (C++) Lab C++ Lab Ra'fat Amareh Faculty of Engineering and Information Technology Assignment Write a C++ program that performs the following: Prints on screen a selection menu as follow: a. Sin (x), Series b. Sum odd digit, Print Digits, Print Shape c. Array d. Exit If user presses a or A, the following sub menu should be displayed 1- Sin (x) (Program should solve the following series x - x'/3! + x®/5! – x/7...x"m!) 2- F (Program should...

  • Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from...

    Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types in the number 42339, the program should print “4 2 3 3 9.” (Hint: The number input is five digits long, dividing it by 10000 gives the leftmost digit. digit1 = number / 10000 ) b. determines...

  • Please write c++ (windows) in simple way and show all the steps with the required output

    please write c++ (windows) in simple way and show all the steps with the required output Write a C++ program that simulates the operation of a simple online banking system The program starts by displaying its main menu as shown in Figure1 splay Account nformatson verity Your credit Card elect vour choice Figure 1 Main menu of the program The menu is composed of the following choices 1. When choice 1 is selected (Display Account information), the program should display...

  • Code in C++ Modify “Producer and Consumer Problem” from lecture note so that it can use...

    Code in C++ Modify “Producer and Consumer Problem” from lecture note so that it can use all buffer space, not “buffersize – 1” as in the lecture note. This program should work as follows: 1.The user will run the program and will enter two numbers on the command line. Those numbers will be used for buffersize and counter limit. 2. The program will then create a separate threads, producer and consumer thread. 3. Producer thread generates a random number through...

  • Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to write a...

    Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to write a menu program for their new Fast-food service machines. Your program already prints the following menu like this: ********************************************************************** McDowell’s Restaurant ********************************************************************** Make your selection from the menu below: 1. Regular Hamburger $1.50 2. Regular Cheeseburger $1.75 3. Fish Sandwich $2.50 4. Half-pounder with cheese $2.75 5. French Fries $0.99 6. Large Soft Drink $1.25 *********************************************************************** Select 1, 2, 3, 4, 5, or 6 -----...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer...

    Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer number, the customer sales, and then the total sales and average sales. You must use two different arrays, one for customer number, and one for sales. These are, in effect, parallel arrays.   You must use a "while" loop to gather customer number and sales....

  • In C++ Programming Write a program in to help a local restaurant automate its breakfast

    Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:Show the customer the different breakfast items offered by the restaurant.Allow the customer to select more than one item from the menu.Calculate and print the bill.Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):Use an array menuList of type menuItemType, as defined in Programming Exercise 3. Your program must contain at least the...

  • Modify your program from Assignment # 7 part b (see below for code) by creating an...

    Modify your program from Assignment # 7 part b (see below for code) by creating an interactive GUI application that displays the list of the orders read in from the file (create a data file using your CreateBankFile.java program which has a least 10 bank account records in it and include it with your submission) and the total number of bank accounts. When your program starts it will first read the records from the Bank Account file (AccountRecords.txt) and creates...

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