Problem 3 (Using different payment methods) Write a program called a2_p3.py where you will be adding options to the previously written code so that users can pay by different methods. Copy your solution from the previous part into the new file (a2_p3.py). Do not overwrite your previous solution, as the TAs will want to see them both. 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: (а) Cash (b) One time pay card Again, the user should make their selection by entering the corresponding character 'a' or 'b’, and bad selections should cause the menu to repeat (see sample outputs below). If customer chooses "Cash', your program should print that payment is completed and program should terminate. If the choice is 'One time pay card' then your program asks for a 4-digit card number and displays the invoice (see the sample output) and terminates. The card number should be exactly a 4-digit positive integer. For bad input repeat the menu (see sample outputs below). You are not supposed to use len() function to check the number of digits. Instead, you should use arithmetic operators you did this in tutorial. Note: To find the last 2 digits 76' of the sample 4-digit number 9876, you must not use any string processing functions. Instead, you should use arithmetic operators that we covered in class. Sample output – 1: . it will first print similar content as shown in the previous part and then How would you like to pay? Select one from the following menu. (а) Cash (b) One time pay card > с Sorry, c is not a valid choice! Please select from the menu. How would you like to pay? Select one from the following menu. (а) Cash (b) One time pay card > b Enter 4 digit card number: 234567 It must be 4 a digit integer, please enter again. Enter 4 digit card number: -4567 Try again, card number must be a positive integer. Enter 4 digit card number: 9876 You have paid by a one time pay card [xx76]. Have a nice day!

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 11SA: 11. What is the purpose of the manipulator setw? Which header file must be included to use the...
icon
Related questions
Question

please I need help

Problem 3 (Using different payment methods)
Write a program called a2_p3.py where you will be adding options to the previously written code
so that users can pay by different methods. Copy your solution from the previous part into the
new file (a2_p3.py). Do not overwrite your previous solution, as the TAs will want to see them
both.
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:
(а) Cash
(b) One time pay card
Again, the user should make their selection by entering the corresponding character ´a' or 'b’, and
bad selections should cause the menu to repeat (see sample outputs below). If customer chooses
"Cash', your program should print that payment is completed and program should terminate. If the
choice is 'One time pay card' then your program asks for a 4-digit card number and displays the
invoice (see the sample output) and terminates. The card number should be exactly a 4-digit
positive integer. For bad input repeat the menu (see sample outputs below). You are not supposed
to use len() function to check the number of digits. Instead, you should use arithmetic operators –
you did this in tutorial.
Note: To find the last 2 digits '76' of the sample 4-digit number 9876, you must not use any
string processing functions. Instead, you should use arithmetic operators that we covered in class.
Sample output – 1:
it will first print similar content as shown in the previous part and then
How would you like to pay? Select one from the following menu.
(а) Cash
(b) One time pay card
> C
Sorry, c is not a valid choice! Please select from the menu.
How would you like to pay? Select one from the following menu.
(а) Cash
(b) One time pay card
> b
Enter 4 digit card number: 234567
It must be 4 a digit integer, please enter again.
Enter 4 digit card number: -4567
Try again, card number must be a positive integer.
Enter 4 digit card number: 9876
You have paid by a one time pay card [xx76]. Have a nice day!
Page 6 of 7
Transcribed Image Text:Problem 3 (Using different payment methods) Write a program called a2_p3.py where you will be adding options to the previously written code so that users can pay by different methods. Copy your solution from the previous part into the new file (a2_p3.py). Do not overwrite your previous solution, as the TAs will want to see them both. 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: (а) Cash (b) One time pay card Again, the user should make their selection by entering the corresponding character ´a' or 'b’, and bad selections should cause the menu to repeat (see sample outputs below). If customer chooses "Cash', your program should print that payment is completed and program should terminate. If the choice is 'One time pay card' then your program asks for a 4-digit card number and displays the invoice (see the sample output) and terminates. The card number should be exactly a 4-digit positive integer. For bad input repeat the menu (see sample outputs below). You are not supposed to use len() function to check the number of digits. Instead, you should use arithmetic operators – you did this in tutorial. Note: To find the last 2 digits '76' of the sample 4-digit number 9876, you must not use any string processing functions. Instead, you should use arithmetic operators that we covered in class. Sample output – 1: it will first print similar content as shown in the previous part and then How would you like to pay? Select one from the following menu. (а) Cash (b) One time pay card > C Sorry, c is not a valid choice! Please select from the menu. How would you like to pay? Select one from the following menu. (а) Cash (b) One time pay card > b Enter 4 digit card number: 234567 It must be 4 a digit integer, please enter again. Enter 4 digit card number: -4567 Try again, card number must be a positive integer. Enter 4 digit card number: 9876 You have paid by a one time pay card [xx76]. Have a nice day! Page 6 of 7
Sample output – 2 (if 'a’ was selected):
How would you like to pay? Select one from the following menu.
(a) Cash
(b) One time pay card
> a
Thank you for your payment. Have a nice day!
Transcribed Image Text:Sample output – 2 (if 'a’ was selected): How would you like to pay? Select one from the following menu. (a) Cash (b) One time pay card > a Thank you for your payment. Have a nice day!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Troubleshooting
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning