Computer Science, asked by Manichandan, 5 months ago

A customer purchases one or more items and gives
the respective quantity for each item to be
purchased. Based on the quantity and price of the
items, display the final amount after discount.
A customer is eligible for 10% discount on total
purchase price above Rs.1000. For total purchase
price below Rs.1000, no discount is given.
Check if customer has a membership with the store.
If he is member, then he gets an extra 5% discount
on every purchase, but if purchase amount of
member is above Rs.1000 then he gets total discount
of 15% on purchase price. For example, if Rajesh does
purchase of Rs. 1800 which is above Rs.1000 and he is
not member of store he gets discount of 10%.
But If Rajesh is'member of store then he gets total
15% discount on Rs.1800 since its above Rs. 1000, but
if he does purchase of Rs.800 which is below Rs. 1000
then he gets only discount of 5%.
Given , Items and price.
Item No. Items Price
1. Yoghurt. 50
2. Cheese. 100
3. Milk. 40
4. Fruit. 200
5. Oil. 300

Calculate the actual price customer has to pay.
Example 1.
1 3 5
2 1 6
y
1649.0 INR​

Answers

Answered by rakshatadevadiga
2

Answer:

Explanation:

items = []

qu=[]

sum=0

n = int(input("Enter total products: "))

for i in range(0, n):

   ele1 = int(input("number of Item:"))

   items.append(ele1) # adding the element

   ele2 = int(input("Quantity:"))

   qu.append(ele2) # adding the element

print(items)

print(qu)

Member = input("enter y or n")

num = {

 1: "Yogurt",

 2: "cheese",

 3: "milk",

 4: "fruit",

 5:"oil"

}

pri = {

"Yogurt": 50,

"cheese":100,

  "milk":40,

"fruit":200,

"oil":300

}

for i in range(0,n):

   check_num=items[i]

   item=num[check_num]

   price=pri[item]

   sum=sum+(price*qu[i])

   

if(Member=="y"):

   if(sum>=1000):

       discount= sum*(15/100)

       total= sum-discount

       print(total," INR")

   else:

       discount= sum*(5/100)

       total= sum-discount

       print(total," INR")

       

else:

   if(sum>=1000):

       discount= sum*(10/100)

       total= sum-discount

       print(total," INR")

   else:

       print(sum," INR")

   

   ----- PS: just dummy code but works well :p

Answered by darammanasa
0

Answer:

inputs = []

prices = [50,100,40,200,300]

while True:

   inp = raw_input()

   if inp.isalpha() == True :

       break

   inputs.append((inp.split()))

member=inp

print(inputs)

if len(inputs[0])!=len(inputs[1]) :

print "INVALID_INPUT 1"

# exit(0)

for i in inputs[0] :

if int(i)>5 :

 print "INVALID_INPUT"

 exit(0)

leng=len(inputs[0])

sum=0

for i in range(0,leng):

l=int(inputs[0][i])-1

k=int(prices[l])

sum=sum+(int(inputs[1][i])*k)

if(sum>1000 and member=='y') :

sum=float(sum-sum*15/100)

elif(sum>1000 and member=='n') :

sum=float(sum-sum*10/100)

elif(sum<1000 and member=='y') :

sum=float(sum-sum*5/100)

print(str(sum)+"INR")

Explanation:

This code calculates the exact cost for the items

Similar questions