This Python project aims to calculate the total bill for customers purchasing medicines from a pharmacy. It also includes a loyalty points system where customers can earn and redeem points based on their purchases and their purchase history.
Upon completing this project, the user will be able to:
shopvisit= int(input("No. of visits"))
point=0
for i in range(1,shopvisit+1):
print("\n\nshopvisit",i)
total = 0
medt=int(input("Enter how many types of medicines customer wants to purchase "))
medqbill = medt
if medt > 0:
for j in range(1,medt+1):
print("medicine type",j)
medq=int(input(f"Enter medicine type{j} quantity "))
if medq > 0:
medc=float(input(f"Enter medicine type{j} cost "))
perMediTotal = medq*medc
total += perMediTotal
else:
print(f"Wrong Input: Quantity entered for type{j} medicine is zero")
medqbill -= 1
curpoint=total//100
if medqbill > 0:
print("Bill is in",i,"visit",total)
print("points earned in",i,"visit",curpoint)
if i==1:
point=curpoint
elif(i>1):
if(point>=10):
pointvalue=point*25
print("If customer want to redeem his points")
ans=input("Enter y/n: ")
if(ans=="Y") or (ans=="y"):
print("Stored points are ", point, "and their value is",pointvalue)
print(f"According to your current bill maximum redeemable points are {total//25} and their value is {25*(total//25)}")
if(total//25) > 0:
redpoint=int(input("How many points you want to redeem "))
if(redpoint<=point):
dis=redpoint*25
if(dis <= total):
FB=total-dis
point-=redpoint
point+=curpoint
print("Total Bill with redeeming",redpoint,"points",FB)
else:
print("Discount is more than total, redeeming not possible")
point+=curpoint
else:
print("Wrong Input: Redeem points given are greater than points")
point+=curpoint
else:
print("No points to redeem")
point+=curpoint
else:
print("Total Bill without redeeming is",total)
point=curpoint+point
else:
FB=total
point=point+curpoint
print("Total Bill when redeeming not possible ",FB)
else:
print("Stored point are not sufficient to redeem")
point=point+curpoint
print("Total points from last visit purchase",point)
else:
print("No bill generated since user didn't purchase anything")
else:
print("Wrong Input: Number of medicine to be purchase are given zero")
shopvisit= int(input("No. of visits"))
point=0
for i in range(1,shopvisit+1):
print("\n\nshopvisit",i)
total = 0
medt=int(input("Enter how many types of medicines customer wants to purchase "))
medqbill = medt
if medt > 0:
for j in range(1,medt+1):
print("medicine type",j)
medq=int(input(f"Enter medicine type{j} quantity "))
if medq > 0:
medc=float(input(f"Enter medicine type{j} cost "))
perMediTotal = medq*medc
total += perMediTotal
else:
print(f"Wrong Input: Quantity entered for type{j} medicine is zero")
medqbill -= 1
curpoint=total//100
if medqbill > 0:
print("Bill is in",i,"visit",total)
print("points earned in",i,"visit",curpoint)
if i==1:
point=curpoint
elif(i>1):
if(point>=10):
pointvalue=point*25
print("If customer want to redeem his points")
ans=input("Enter y/n: ")
if(ans=="Y") or (ans=="y"):
print("Stored points are ", point, "and their value is",pointvalue)
print(f"According to your current bill maximum redeemable points are {total//25} and their value is {25*(total//25)}")
if(total//25) > 0:
redpoint=int(input("How many points you want to redeem "))
if(redpoint<=point):
dis=redpoint*25
if(dis <= total):
FB=total-dis
point-=redpoint
point+=curpoint
print("Total Bill with redeeming",redpoint,"points",FB)
else:
print("Discount is more than total, redeeming not possible")
point+=curpoint
else:
print("Wrong Input: Redeem points given are greater than points")
point+=curpoint
else:
print("No points to redeem")
point+=curpoint
else:
print("Total Bill without redeeming is",total)
point=curpoint+point
else:
FB=total
point=point+curpoint
print("Total Bill when redeeming not possible ",FB)
else:
print("Stored point are not sufficient to redeem")
point=point+curpoint
print("Total points from last visit purchase",point)
else:
print("No bill generated since user didn't purchase anything")
else:
print("Wrong Input: Number of medicine to be purchase are given zero")
Initialize shopvisit to User Input ("No. of visits")
Initialize point to 0
FOR i from 1 to shopvisit
PRINT "shopvisit", i
Initialize total to 0
Initialize medt to User Input ("Enter how many types of medicines customer wants to purchase")
Initialize medqbill to medt
IF medt > 0 THEN
FOR j from 1 to medt
PRINT "medicine type", j
Initialize medq to User Input ("Enter medicine type[j] quantity")
IF medq > 0 THEN
Initialize medc to User Input ("Enter medicine type[j] cost")
Calculate perMediTotal as medq * medc
Update total by adding perMediTotal
ELSE
PRINT "Wrong Input: Quantity entered for type[j] medicine is zero"
Decrement medqbill by 1
END IF
END FOR
Calculate curpoint as total // 100
IF medqbill > 0 THEN
PRINT "Bill is in", i, "visit", total
PRINT "points earned in", i, "visit", curpoint
IF i == 1 THEN
point = curpoint
ELSE IF i > 1 THEN
IF point >= 10 THEN
Calculate pointvalue as point * 25
PRINT "If customer wants to redeem his points"
Initialize ans to User Input ("Enter y/n")
IF ans is 'y' or 'Y' THEN
// Redemption logic here
ELSE
PRINT "Total Bill without redeeming is", total
point = point + curpoint
END IF
ELSE
PRINT "Total Bill when redeeming not possible", total
point = point + curpoint
END IF
END IF
ELSE
PRINT "No bill generated since user didn't purchase anything"
END IF
ELSE
PRINT "Wrong Input: Number of medicine to be purchased are given zero"
END IF
END FOR
Initialize shopvisit to User Input ("No. of visits")
Initialize point to 0
FOR i from 1 to shopvisit
PRINT "shopvisit", i
Initialize total to 0
Initialize medt to User Input ("Enter how many types of medicines customer wants to purchase")
Initialize medqbill to medt
IF medt > 0 THEN
FOR j from 1 to medt
PRINT "medicine type", j
Initialize medq to User Input ("Enter medicine type[j] quantity")
IF medq > 0 THEN
Initialize medc to User Input ("Enter medicine type[j] cost")
Calculate perMediTotal as medq * medc
Update total by adding perMediTotal
ELSE
PRINT "Wrong Input: Quantity entered for type[j] medicine is zero"
Decrement medqbill by 1
END IF
END FOR
Calculate curpoint as total // 100
IF medqbill > 0 THEN
PRINT "Bill is in", i, "visit", total
PRINT "points earned in", i, "visit", curpoint
IF i == 1 THEN
point = curpoint
ELSE IF i > 1 THEN
IF point >= 10 THEN
Calculate pointvalue as point * 25
PRINT "If customer wants to redeem his points"
Initialize ans to User Input ("Enter y/n")
IF ans is 'y' or 'Y' THEN
// Redemption logic here
ELSE
PRINT "Total Bill without redeeming is", total
point = point + curpoint
END IF
ELSE
PRINT "Total Bill when redeeming not possible", total
point = point + curpoint
END IF
END IF
ELSE
PRINT "No bill generated since user didn't purchase anything"
END IF
ELSE
PRINT "Wrong Input: Number of medicine to be purchased are given zero"
END IF
END FOR
Invalid Input: The code handles invalid inputs by displaying an error message and not including them in the bill or points calculation.
Office:- 660, Sector 14A, Vasundhara, Ghaziabad, Uttar Pradesh - 201012, India