Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program, which runs a simple invoice printer to be used by a retailer. The retailer is prompted for item identification, quantity and
Write a program, which runs a simple invoice printer to be used by a retailer. The retailer is prompted for item identification, quantity and unit price of each item he/she wishes to include in the invoice. When no more items need to be included, the retailer enters "done". The invoice is then printed similarly to the model below. The item identification should be at least 3 characters long, the quantity should be a strictly positive integer > 0 and the cost a strictly positive float > 0. If any of these conditions is broken, ignore the whole current item and prompt for a new one. The invoice itemization text should be composed progressively and stored in one string that spans multiple lines. To do that, you should include new line characters at the proper positions of the string. Sample run: 1 This program prints your invoices. 2 Please enter the item identification, item cost and quantity sold when prompted. Enter 'done' when no more items 3 ========= 4 =======item========== 5 Item identification: pen123 6 Qty sold: 3 7 Item price: 3.5 8=======item========== 9 Item identification: st 10 Item identification should be at least 3 characters long 11 =======item==== 12 Item identification: staples45 13 Qty sold: 7.5 14 Quantity should be an integer value 15 =======item========== 16 Item identification: staples45 17 Qty sold: 7 18 Item price: ccc 19 Item price should be a numerical value 20=======item========== 21 Item identification: staples45 22 Qty sold: 7 23 Item price: 4.25 24 =======item========== 25 Item identification: paper10 26 Qty sold: 5 27 Item price: 17.75 28 ======= item========== 29 Item identification: done 30 ====== ===========Invoice===== 31 3 x pen123@SAR 3.5 === 10.5 32 7 x staples45 @ SAR 4.25 === 29.75 33 5 x paper10@SAR 17.75 === 88.75 34 35 ====== 36 Total= SAR 129.0 ======= ========
Step by Step Solution
There are 3 Steps involved in it
Step: 1
python def isvaliditemiditemid return lenitemid 3 def isvalidquantityquantity try quantity intquantity return quantity 0 except ValueError return Fals...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started