Answer to Question #305525 in Python for Niña

Question #305525

Using the Fare Matrix above, create a Python program (using any of the selection structures) that will accept distance in kilometer/s as input, and student or elderly passengers will pay the discounted rate, disabled passengers will get an additional 10% discount with the original discounted rate, otherwise the regular fare will be used as basis for the computation of fare. The output will be the total fare for the passenger.

1
Expert's answer
2022-03-03T09:59:28-0500
STUDENT = 1
ELDER   = 2


UnitFare = 2


Flag=1
while(Flag):
    c=0
    while(c<1 or c>2):
        c = int(input("Press 1 for student or 2 for elder: "))
    Dist=0
    while(Dist<=0):
        Dist = int(input("Press Distance in Kms. (>0): "))
    Fare = UnitFare*Dist
    print("\nTotal Fare = ",round(Fare,2))
    Discount=0
    if(c==STUDENT):
        Discount = 0
    if(c==ELDER):
        Discount = 0.10*Fare
    NetFare = Fare - Discount
    print("Discount = ",round(Discount,2))
    print("Net Fare = ",round(NetFare,2))      
    Flag = int(input("\nPress 1 to continue or 0 to QUIT: ")) 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS