Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN python .. could i get the answer of this question please .. thank you III . The functions mentioned in section (I) may raise

IN python .. could i get the answer of this question please ..

thank you

image text in transcribedimage text in transcribed

III. The functions mentioned in section (I) may raise Errors/Exceptions.You are then requested to handle the following error situations.

a. Input file not found, in which case an adequate error message should be displayed.

b. Invalid data (such as Unit price not strictly positive or not a number, quantity not strictly positive or not a whole number, incorrect discount code) in which case display the ID number and the product description found in the file followed by the adequate error message.

c. Discount rate not

a. in the range 0-25% in which case replace it by 5%.

b. a number in which case replace it by 0%.

c. equal to 0 when discount code is equal to N in which case replace it by 0%.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

# this is input file:

2145:Socks:5:1.1:N:0.20 5896:Jacket:5:60.50:L:0.10 6321:Belt:40:12.1:F:0.9 4552:Tee-Shirt:15:-4.25:F:0.12 2356:Shirt:5:10.2:M:0 2589:Veil:60:7.1:F:0.15 

Figure.1: Sample input file ... (purchase.txt)

Problem Definition A seller keeps a record for each purchase in a text file. Each line in the file contains six items. The ID, the product description, the quantity, the unit price, the discount code (one of the letter S', F' or N'), and the discount rate (between 0-25%). Items are separated by colons. Figure. I shows a sample input file. 2145: Socks:5:1.1:S:0.20 5896: Jacket:5:60.50:L:0.10 6321 :Belt: 40:12.1:F:0.9 4552:Tee-Shirt:15:-4.25:F:0.12 2356:Shirt:5:10.2:M:0 2589: Veil:60:7.1:F:0.15 Figure. 1: Sample input file It is worth mentioning that the discounted price is calculated on the basis of the discount code, the discount rate, and in some instances the quantity. Hence, based on each of the following discount code, the discounted price is calculated as follows: 1. 'S': a standard discount is applied. Discounted price Unit Price x (1- discount rate). 2. 'F' a full discount is applied. If the quantity is less than 50 then the Discounted price unit Price x (1 -3x discount rate) otherwise Discounted price unit Price /3 3. 'N' no discount will be applied

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago