Write a program that operates like a point of sale terminal for the purchase of three items in various quantities. The program should accept the name, unit price, and quantity of each item as keyboard inputs. Note that the prompts for the price and quantity should display the item name. A line should be printed that reflects these inputs and includes the subtotal for each item. The program should finish by printing the total for the three items.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a program that operates like a point of sale terminal for the purchase of three items in various quantities. The program should accept the name, unit price, and quantity of each item as keyboard inputs. Note that the prompts for the price and quantity should display the item name. A line should be printed that reflects these inputs and includes the subtotal for each item. The program should finish by printing the total for the three items.

 

Attached is the example output and my code thus far. 

def main():
item = input ('Enter item name ')
total = 0.0
while (item == 'shirts' or 'shorts' or 'hats'):
while item == 'shirts':
float(input('Enter unit price of shirts '))
= int(input('Enter quantity of shirts '))
price
quantity
shirts_total = quantity * price
print(f'{quantity} shirts @ ${price}, total ${shirts_total:.2f}')
item = input ('Enter item name ')
while item ==
price = float (input ('Enter unit price of shorts '))
quantity = int(input('Enter quantity of shorts '))
shorts_total = quantity * price
print (f'{quantity} shorts @ ${price:.2f}, total ${shorts_total:.2f}')
item = input ('Enter item name ')
2w66 item == 'hats' :
price = float (input|('Enter unit price of hats '))
quantity = int(input ('Enter quantity of hats '))
hats_total
print(f'{quantity} hats @ ${price:.2f}, total ${hats_total:.2f}')
%3D
'shorts':
quantity * price
%D
if hats_total >0:
print (f'Total of these three items is ${shirts_total + shorts_total + hats_total:.2f}')
main()
Transcribed Image Text:def main(): item = input ('Enter item name ') total = 0.0 while (item == 'shirts' or 'shorts' or 'hats'): while item == 'shirts': float(input('Enter unit price of shirts ')) = int(input('Enter quantity of shirts ')) price quantity shirts_total = quantity * price print(f'{quantity} shirts @ ${price}, total ${shirts_total:.2f}') item = input ('Enter item name ') while item == price = float (input ('Enter unit price of shorts ')) quantity = int(input('Enter quantity of shorts ')) shorts_total = quantity * price print (f'{quantity} shorts @ ${price:.2f}, total ${shorts_total:.2f}') item = input ('Enter item name ') 2w66 item == 'hats' : price = float (input|('Enter unit price of hats ')) quantity = int(input ('Enter quantity of hats ')) hats_total print(f'{quantity} hats @ ${price:.2f}, total ${hats_total:.2f}') %3D 'shorts': quantity * price %D if hats_total >0: print (f'Total of these three items is ${shirts_total + shorts_total + hats_total:.2f}') main()
Example Output
Enter item name shirts
Enter unit price of shirts 29.99
Enter quantity of shirts 3
3 shirts @ $29.99, total $89.97
Enter item name shorts
Enter unit price of shorts 19.95
Enter quantity of shorts 2
2 shorts @ $19.95, total $39.90
Enter item name hats
Enter unit price of h prob42 4.99
Enter quantity of hats 3
3 hats @ $14.99, total $44.97
Total of these three items is $174.84
Transcribed Image Text:Example Output Enter item name shirts Enter unit price of shirts 29.99 Enter quantity of shirts 3 3 shirts @ $29.99, total $89.97 Enter item name shorts Enter unit price of shorts 19.95 Enter quantity of shorts 2 2 shorts @ $19.95, total $39.90 Enter item name hats Enter unit price of h prob42 4.99 Enter quantity of hats 3 3 hats @ $14.99, total $44.97 Total of these three items is $174.84
Expert Solution
Step 1

Program's information is given.

The objective is to write the program that operates like a point of sale terminal for the purchase of three items in various quantities.

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY