Taxi fare calculator, trip recorder, and fuel calculator

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I solved this practice problem in preparation for school exams.




The owner of a taxi company wants a system that calculates how much money his taxis take in one day.



Write and test a program for the owner.



  • Your program must include appropriate prompts for the entry of data.


  • Error messages and other output need to be set out clearly and understandably.


  • All variables, constants and other identifiers must have meaningful names.


You will need to complete these three tasks. Each task must be fully tested.



TASK 1 – calculate the money owed for one trip



The cost of a trip in a taxi is calculated based on the numbers of KMs traveled and the type of taxi that you are traveling in. The taxi company has three different types of taxi available:



  • a saloon car, that seats up to 4,

  • a people carrier, that seats up 8,

  • a mini-van, that seats up to 12.

For a trip in a saloon car the base amount is RM2.50 and then a charge of RM1.00 per KM. For a trip in a people carrier the base amount is RM4.00 and a charge of RM1.25 per KM. For a trip in a mini- van the base amount is RM5.00 and a charge of RM1.50 per KM. The minimum trip length is 3KM and the maximum trip length is 50KM. Once the trip is complete a 6% service tax is added.



TASK 2 – record what happens in a day



The owner of the taxi company wants to keep a record of the journeys done by each one of his taxis in a day. For each one of his three taxis record the length of each trip and the number of people carried. Your program should store a maximum of 24 trips or 350km worth of trips, whichever comes first. Your program should be able to output a list of the jobs done by each one of the three taxis.



TASK 3 – calculate the money taken for all the taxis at the end of the day.



At the end of the day use the data stored for each taxi to calculate the total amount of money taken and the total number of people carried by each one of the three taxis. Using the average price of RM2.79 per litre use the information in the table below to calculate the fuel cost for each taxi:



  • the saloon car uses 7.4L/100km

  • the people carrier uses 8.6L/100km

  • and the mini-van uses 9.2L/100km

Provide a report for the owner to show this information.




Here is my rather messy solution:



saloon = 
people_car =
mini =
count = 0

total_seats = 0
total_cost = 0

mini_distance = 0
sln_distance = 0
ppl_distance = 0

def check(distance):
try:
distance = float(distance)
except ValueError:
print("Enter a number")
return False

while True:
print("[1] Add to List (" + repr(count) + " entered)")
print("[2] View List")
print("[3] View Information and Costs")
print("[4] Exit")
menu = input("Enter command: ")

if menu == "1":
clarify = input("Add to list? (yes/no) ")

if clarify == "yes" and count < 25:
while True:

if count > 24:
print("You have reached the maximum amount of list inputs!")
break

seats = input("How many riders? (type exit to exit) ")

try:
seats = int(seats)
except ValueError:
print("Please enter a number n=======================================")
pass
break

if int(seats) > 0 and int(seats) < 5:
car_type = input("You will be taking the saloon car? (yes/no) ")
if car_type == "yes":
distance = input("How far was the trip? ")
if check(distance) == False:
break

if distance > 0 and distance < 51 and sln_distance < 351:
count += 1
len_sum = float(2.50) + distance
total_sum = len_sum * 1.06
print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
saloon.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
total_seats += seats
total_cost += round(total_sum, 2)
sln_distance += distance

elif sln_distance > 350:
print("This car has reached it's limit")

elif distance < 1 or distance > 50:
print("Please enter a valid distance between 1 and 50")

else:
print("Have you tried digits?")

elif car_type == "no":
print("Command cancelled")

else:
print("Please redo")


if int(seats) > 4 and int(seats) < 9:
car_type = input("You will be taking the people carrier? (yes/no)")
if car_type == "yes":
distance = input("How far was the trip? ")
if check(distance) == False:
break

if distance > 0 and distance < 51:
count += 1
dis_cos = distance * 1.25
len_sum = float(4) + dis_cos
total_sum = len_sum * 1.06
print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
people_car.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
total_seats += seats
total_cost += round(total_sum, 2)
ppl_distance += distance

elif ppl_distance > 350:
print("This car has reached it's limit")

elif distance < 1 or distance > 50:
print("Please enter a valid distance between 1 and 50")

else:
print("Have you tried digits?")

elif car_type == "no":
print("Please redo")

else:
print("Please redo")

if int(seats) > 8 and int(seats) < 13:
car_type = input("You will be taking the mini van? (yes/no)")
if car_type == "yes":
distance = input("How far was the trip? ")
if check(distance) == False:
break

if distance > 0 and distance < 51:
count += 1
dis_cos = distance * 1.5
len_sum = float(5) + dis_cos
total_sum = len_sum * 1.06
print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
mini.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
total_seats += seats
total_cost += round(total_sum, 2)
mini_distance += distance

elif mini_distance > 350:
print("This car has reached it's limit")

elif distance < 1 or distance > 50:
print("Please enter a valid distance between 1 and 50")

else:
print("Have you tried digits?")

elif car_type == "no":
print("Please redo")

else:
print("Please enter a valid answer")

elif seats == "exit":
break

elif seats < 1 or seats > 12:
print("Enter within the given range")



elif (not int(seats) > 0) or (not int(seats) < 13) or (not seats == "exit"):
print("========================================")


if clarify == "no":
break

else:
continue

else:
print("Please redo n=======================================")

elif count == int(24):
count += 1
print("You have reached the maximum amount of list inputs!")

elif menu == "2":
print("Saloon: " + ' '.join(saloon) + "nPeople carrier: " + ' '.join(people_car) + "nMini van: " + ' '.join(mini))
print("========================================")

elif menu == "3":

print("Riders: " + repr(total_seats) + "nCost: RM" + repr(total_cost))

def calc(a):
avg_cost = float(a) / 100
return avg_cost * 7.4

final_sln = float(calc(sln_distance))
final_ppl = float(calc(ppl_distance))
final_mini = float(calc(mini_distance))

print("Saloon fuel cost: RM" + repr(round(final_sln, 2)))
print("People carrier fuel cost: RM" + repr(round(final_ppl, 2)))
print("Mini van fuel cost: RM" + repr(round(final_mini, 2)))
print("========================================")

elif menu == "4":
prompt = input("Exit program? (yes/no)")
if prompt == "yes":
exit()
else:
print("Command canceled")
continue









share|improve this question



























    up vote
    1
    down vote

    favorite












    I solved this practice problem in preparation for school exams.




    The owner of a taxi company wants a system that calculates how much money his taxis take in one day.



    Write and test a program for the owner.



    • Your program must include appropriate prompts for the entry of data.


    • Error messages and other output need to be set out clearly and understandably.


    • All variables, constants and other identifiers must have meaningful names.


    You will need to complete these three tasks. Each task must be fully tested.



    TASK 1 – calculate the money owed for one trip



    The cost of a trip in a taxi is calculated based on the numbers of KMs traveled and the type of taxi that you are traveling in. The taxi company has three different types of taxi available:



    • a saloon car, that seats up to 4,

    • a people carrier, that seats up 8,

    • a mini-van, that seats up to 12.

    For a trip in a saloon car the base amount is RM2.50 and then a charge of RM1.00 per KM. For a trip in a people carrier the base amount is RM4.00 and a charge of RM1.25 per KM. For a trip in a mini- van the base amount is RM5.00 and a charge of RM1.50 per KM. The minimum trip length is 3KM and the maximum trip length is 50KM. Once the trip is complete a 6% service tax is added.



    TASK 2 – record what happens in a day



    The owner of the taxi company wants to keep a record of the journeys done by each one of his taxis in a day. For each one of his three taxis record the length of each trip and the number of people carried. Your program should store a maximum of 24 trips or 350km worth of trips, whichever comes first. Your program should be able to output a list of the jobs done by each one of the three taxis.



    TASK 3 – calculate the money taken for all the taxis at the end of the day.



    At the end of the day use the data stored for each taxi to calculate the total amount of money taken and the total number of people carried by each one of the three taxis. Using the average price of RM2.79 per litre use the information in the table below to calculate the fuel cost for each taxi:



    • the saloon car uses 7.4L/100km

    • the people carrier uses 8.6L/100km

    • and the mini-van uses 9.2L/100km

    Provide a report for the owner to show this information.




    Here is my rather messy solution:



    saloon = 
    people_car =
    mini =
    count = 0

    total_seats = 0
    total_cost = 0

    mini_distance = 0
    sln_distance = 0
    ppl_distance = 0

    def check(distance):
    try:
    distance = float(distance)
    except ValueError:
    print("Enter a number")
    return False

    while True:
    print("[1] Add to List (" + repr(count) + " entered)")
    print("[2] View List")
    print("[3] View Information and Costs")
    print("[4] Exit")
    menu = input("Enter command: ")

    if menu == "1":
    clarify = input("Add to list? (yes/no) ")

    if clarify == "yes" and count < 25:
    while True:

    if count > 24:
    print("You have reached the maximum amount of list inputs!")
    break

    seats = input("How many riders? (type exit to exit) ")

    try:
    seats = int(seats)
    except ValueError:
    print("Please enter a number n=======================================")
    pass
    break

    if int(seats) > 0 and int(seats) < 5:
    car_type = input("You will be taking the saloon car? (yes/no) ")
    if car_type == "yes":
    distance = input("How far was the trip? ")
    if check(distance) == False:
    break

    if distance > 0 and distance < 51 and sln_distance < 351:
    count += 1
    len_sum = float(2.50) + distance
    total_sum = len_sum * 1.06
    print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
    saloon.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
    total_seats += seats
    total_cost += round(total_sum, 2)
    sln_distance += distance

    elif sln_distance > 350:
    print("This car has reached it's limit")

    elif distance < 1 or distance > 50:
    print("Please enter a valid distance between 1 and 50")

    else:
    print("Have you tried digits?")

    elif car_type == "no":
    print("Command cancelled")

    else:
    print("Please redo")


    if int(seats) > 4 and int(seats) < 9:
    car_type = input("You will be taking the people carrier? (yes/no)")
    if car_type == "yes":
    distance = input("How far was the trip? ")
    if check(distance) == False:
    break

    if distance > 0 and distance < 51:
    count += 1
    dis_cos = distance * 1.25
    len_sum = float(4) + dis_cos
    total_sum = len_sum * 1.06
    print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
    people_car.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
    total_seats += seats
    total_cost += round(total_sum, 2)
    ppl_distance += distance

    elif ppl_distance > 350:
    print("This car has reached it's limit")

    elif distance < 1 or distance > 50:
    print("Please enter a valid distance between 1 and 50")

    else:
    print("Have you tried digits?")

    elif car_type == "no":
    print("Please redo")

    else:
    print("Please redo")

    if int(seats) > 8 and int(seats) < 13:
    car_type = input("You will be taking the mini van? (yes/no)")
    if car_type == "yes":
    distance = input("How far was the trip? ")
    if check(distance) == False:
    break

    if distance > 0 and distance < 51:
    count += 1
    dis_cos = distance * 1.5
    len_sum = float(5) + dis_cos
    total_sum = len_sum * 1.06
    print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
    mini.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
    total_seats += seats
    total_cost += round(total_sum, 2)
    mini_distance += distance

    elif mini_distance > 350:
    print("This car has reached it's limit")

    elif distance < 1 or distance > 50:
    print("Please enter a valid distance between 1 and 50")

    else:
    print("Have you tried digits?")

    elif car_type == "no":
    print("Please redo")

    else:
    print("Please enter a valid answer")

    elif seats == "exit":
    break

    elif seats < 1 or seats > 12:
    print("Enter within the given range")



    elif (not int(seats) > 0) or (not int(seats) < 13) or (not seats == "exit"):
    print("========================================")


    if clarify == "no":
    break

    else:
    continue

    else:
    print("Please redo n=======================================")

    elif count == int(24):
    count += 1
    print("You have reached the maximum amount of list inputs!")

    elif menu == "2":
    print("Saloon: " + ' '.join(saloon) + "nPeople carrier: " + ' '.join(people_car) + "nMini van: " + ' '.join(mini))
    print("========================================")

    elif menu == "3":

    print("Riders: " + repr(total_seats) + "nCost: RM" + repr(total_cost))

    def calc(a):
    avg_cost = float(a) / 100
    return avg_cost * 7.4

    final_sln = float(calc(sln_distance))
    final_ppl = float(calc(ppl_distance))
    final_mini = float(calc(mini_distance))

    print("Saloon fuel cost: RM" + repr(round(final_sln, 2)))
    print("People carrier fuel cost: RM" + repr(round(final_ppl, 2)))
    print("Mini van fuel cost: RM" + repr(round(final_mini, 2)))
    print("========================================")

    elif menu == "4":
    prompt = input("Exit program? (yes/no)")
    if prompt == "yes":
    exit()
    else:
    print("Command canceled")
    continue









    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I solved this practice problem in preparation for school exams.




      The owner of a taxi company wants a system that calculates how much money his taxis take in one day.



      Write and test a program for the owner.



      • Your program must include appropriate prompts for the entry of data.


      • Error messages and other output need to be set out clearly and understandably.


      • All variables, constants and other identifiers must have meaningful names.


      You will need to complete these three tasks. Each task must be fully tested.



      TASK 1 – calculate the money owed for one trip



      The cost of a trip in a taxi is calculated based on the numbers of KMs traveled and the type of taxi that you are traveling in. The taxi company has three different types of taxi available:



      • a saloon car, that seats up to 4,

      • a people carrier, that seats up 8,

      • a mini-van, that seats up to 12.

      For a trip in a saloon car the base amount is RM2.50 and then a charge of RM1.00 per KM. For a trip in a people carrier the base amount is RM4.00 and a charge of RM1.25 per KM. For a trip in a mini- van the base amount is RM5.00 and a charge of RM1.50 per KM. The minimum trip length is 3KM and the maximum trip length is 50KM. Once the trip is complete a 6% service tax is added.



      TASK 2 – record what happens in a day



      The owner of the taxi company wants to keep a record of the journeys done by each one of his taxis in a day. For each one of his three taxis record the length of each trip and the number of people carried. Your program should store a maximum of 24 trips or 350km worth of trips, whichever comes first. Your program should be able to output a list of the jobs done by each one of the three taxis.



      TASK 3 – calculate the money taken for all the taxis at the end of the day.



      At the end of the day use the data stored for each taxi to calculate the total amount of money taken and the total number of people carried by each one of the three taxis. Using the average price of RM2.79 per litre use the information in the table below to calculate the fuel cost for each taxi:



      • the saloon car uses 7.4L/100km

      • the people carrier uses 8.6L/100km

      • and the mini-van uses 9.2L/100km

      Provide a report for the owner to show this information.




      Here is my rather messy solution:



      saloon = 
      people_car =
      mini =
      count = 0

      total_seats = 0
      total_cost = 0

      mini_distance = 0
      sln_distance = 0
      ppl_distance = 0

      def check(distance):
      try:
      distance = float(distance)
      except ValueError:
      print("Enter a number")
      return False

      while True:
      print("[1] Add to List (" + repr(count) + " entered)")
      print("[2] View List")
      print("[3] View Information and Costs")
      print("[4] Exit")
      menu = input("Enter command: ")

      if menu == "1":
      clarify = input("Add to list? (yes/no) ")

      if clarify == "yes" and count < 25:
      while True:

      if count > 24:
      print("You have reached the maximum amount of list inputs!")
      break

      seats = input("How many riders? (type exit to exit) ")

      try:
      seats = int(seats)
      except ValueError:
      print("Please enter a number n=======================================")
      pass
      break

      if int(seats) > 0 and int(seats) < 5:
      car_type = input("You will be taking the saloon car? (yes/no) ")
      if car_type == "yes":
      distance = input("How far was the trip? ")
      if check(distance) == False:
      break

      if distance > 0 and distance < 51 and sln_distance < 351:
      count += 1
      len_sum = float(2.50) + distance
      total_sum = len_sum * 1.06
      print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
      saloon.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
      total_seats += seats
      total_cost += round(total_sum, 2)
      sln_distance += distance

      elif sln_distance > 350:
      print("This car has reached it's limit")

      elif distance < 1 or distance > 50:
      print("Please enter a valid distance between 1 and 50")

      else:
      print("Have you tried digits?")

      elif car_type == "no":
      print("Command cancelled")

      else:
      print("Please redo")


      if int(seats) > 4 and int(seats) < 9:
      car_type = input("You will be taking the people carrier? (yes/no)")
      if car_type == "yes":
      distance = input("How far was the trip? ")
      if check(distance) == False:
      break

      if distance > 0 and distance < 51:
      count += 1
      dis_cos = distance * 1.25
      len_sum = float(4) + dis_cos
      total_sum = len_sum * 1.06
      print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
      people_car.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
      total_seats += seats
      total_cost += round(total_sum, 2)
      ppl_distance += distance

      elif ppl_distance > 350:
      print("This car has reached it's limit")

      elif distance < 1 or distance > 50:
      print("Please enter a valid distance between 1 and 50")

      else:
      print("Have you tried digits?")

      elif car_type == "no":
      print("Please redo")

      else:
      print("Please redo")

      if int(seats) > 8 and int(seats) < 13:
      car_type = input("You will be taking the mini van? (yes/no)")
      if car_type == "yes":
      distance = input("How far was the trip? ")
      if check(distance) == False:
      break

      if distance > 0 and distance < 51:
      count += 1
      dis_cos = distance * 1.5
      len_sum = float(5) + dis_cos
      total_sum = len_sum * 1.06
      print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
      mini.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
      total_seats += seats
      total_cost += round(total_sum, 2)
      mini_distance += distance

      elif mini_distance > 350:
      print("This car has reached it's limit")

      elif distance < 1 or distance > 50:
      print("Please enter a valid distance between 1 and 50")

      else:
      print("Have you tried digits?")

      elif car_type == "no":
      print("Please redo")

      else:
      print("Please enter a valid answer")

      elif seats == "exit":
      break

      elif seats < 1 or seats > 12:
      print("Enter within the given range")



      elif (not int(seats) > 0) or (not int(seats) < 13) or (not seats == "exit"):
      print("========================================")


      if clarify == "no":
      break

      else:
      continue

      else:
      print("Please redo n=======================================")

      elif count == int(24):
      count += 1
      print("You have reached the maximum amount of list inputs!")

      elif menu == "2":
      print("Saloon: " + ' '.join(saloon) + "nPeople carrier: " + ' '.join(people_car) + "nMini van: " + ' '.join(mini))
      print("========================================")

      elif menu == "3":

      print("Riders: " + repr(total_seats) + "nCost: RM" + repr(total_cost))

      def calc(a):
      avg_cost = float(a) / 100
      return avg_cost * 7.4

      final_sln = float(calc(sln_distance))
      final_ppl = float(calc(ppl_distance))
      final_mini = float(calc(mini_distance))

      print("Saloon fuel cost: RM" + repr(round(final_sln, 2)))
      print("People carrier fuel cost: RM" + repr(round(final_ppl, 2)))
      print("Mini van fuel cost: RM" + repr(round(final_mini, 2)))
      print("========================================")

      elif menu == "4":
      prompt = input("Exit program? (yes/no)")
      if prompt == "yes":
      exit()
      else:
      print("Command canceled")
      continue









      share|improve this question















      I solved this practice problem in preparation for school exams.




      The owner of a taxi company wants a system that calculates how much money his taxis take in one day.



      Write and test a program for the owner.



      • Your program must include appropriate prompts for the entry of data.


      • Error messages and other output need to be set out clearly and understandably.


      • All variables, constants and other identifiers must have meaningful names.


      You will need to complete these three tasks. Each task must be fully tested.



      TASK 1 – calculate the money owed for one trip



      The cost of a trip in a taxi is calculated based on the numbers of KMs traveled and the type of taxi that you are traveling in. The taxi company has three different types of taxi available:



      • a saloon car, that seats up to 4,

      • a people carrier, that seats up 8,

      • a mini-van, that seats up to 12.

      For a trip in a saloon car the base amount is RM2.50 and then a charge of RM1.00 per KM. For a trip in a people carrier the base amount is RM4.00 and a charge of RM1.25 per KM. For a trip in a mini- van the base amount is RM5.00 and a charge of RM1.50 per KM. The minimum trip length is 3KM and the maximum trip length is 50KM. Once the trip is complete a 6% service tax is added.



      TASK 2 – record what happens in a day



      The owner of the taxi company wants to keep a record of the journeys done by each one of his taxis in a day. For each one of his three taxis record the length of each trip and the number of people carried. Your program should store a maximum of 24 trips or 350km worth of trips, whichever comes first. Your program should be able to output a list of the jobs done by each one of the three taxis.



      TASK 3 – calculate the money taken for all the taxis at the end of the day.



      At the end of the day use the data stored for each taxi to calculate the total amount of money taken and the total number of people carried by each one of the three taxis. Using the average price of RM2.79 per litre use the information in the table below to calculate the fuel cost for each taxi:



      • the saloon car uses 7.4L/100km

      • the people carrier uses 8.6L/100km

      • and the mini-van uses 9.2L/100km

      Provide a report for the owner to show this information.




      Here is my rather messy solution:



      saloon = 
      people_car =
      mini =
      count = 0

      total_seats = 0
      total_cost = 0

      mini_distance = 0
      sln_distance = 0
      ppl_distance = 0

      def check(distance):
      try:
      distance = float(distance)
      except ValueError:
      print("Enter a number")
      return False

      while True:
      print("[1] Add to List (" + repr(count) + " entered)")
      print("[2] View List")
      print("[3] View Information and Costs")
      print("[4] Exit")
      menu = input("Enter command: ")

      if menu == "1":
      clarify = input("Add to list? (yes/no) ")

      if clarify == "yes" and count < 25:
      while True:

      if count > 24:
      print("You have reached the maximum amount of list inputs!")
      break

      seats = input("How many riders? (type exit to exit) ")

      try:
      seats = int(seats)
      except ValueError:
      print("Please enter a number n=======================================")
      pass
      break

      if int(seats) > 0 and int(seats) < 5:
      car_type = input("You will be taking the saloon car? (yes/no) ")
      if car_type == "yes":
      distance = input("How far was the trip? ")
      if check(distance) == False:
      break

      if distance > 0 and distance < 51 and sln_distance < 351:
      count += 1
      len_sum = float(2.50) + distance
      total_sum = len_sum * 1.06
      print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
      saloon.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
      total_seats += seats
      total_cost += round(total_sum, 2)
      sln_distance += distance

      elif sln_distance > 350:
      print("This car has reached it's limit")

      elif distance < 1 or distance > 50:
      print("Please enter a valid distance between 1 and 50")

      else:
      print("Have you tried digits?")

      elif car_type == "no":
      print("Command cancelled")

      else:
      print("Please redo")


      if int(seats) > 4 and int(seats) < 9:
      car_type = input("You will be taking the people carrier? (yes/no)")
      if car_type == "yes":
      distance = input("How far was the trip? ")
      if check(distance) == False:
      break

      if distance > 0 and distance < 51:
      count += 1
      dis_cos = distance * 1.25
      len_sum = float(4) + dis_cos
      total_sum = len_sum * 1.06
      print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
      people_car.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
      total_seats += seats
      total_cost += round(total_sum, 2)
      ppl_distance += distance

      elif ppl_distance > 350:
      print("This car has reached it's limit")

      elif distance < 1 or distance > 50:
      print("Please enter a valid distance between 1 and 50")

      else:
      print("Have you tried digits?")

      elif car_type == "no":
      print("Please redo")

      else:
      print("Please redo")

      if int(seats) > 8 and int(seats) < 13:
      car_type = input("You will be taking the mini van? (yes/no)")
      if car_type == "yes":
      distance = input("How far was the trip? ")
      if check(distance) == False:
      break

      if distance > 0 and distance < 51:
      count += 1
      dis_cos = distance * 1.5
      len_sum = float(5) + dis_cos
      total_sum = len_sum * 1.06
      print("Price is: RM" + repr(round(total_sum, 2)) + "n=======================================")
      mini.append("Riders: " + repr(seats) + "Revenue: RM" + repr(round(total_sum, 2)) + " | ")
      total_seats += seats
      total_cost += round(total_sum, 2)
      mini_distance += distance

      elif mini_distance > 350:
      print("This car has reached it's limit")

      elif distance < 1 or distance > 50:
      print("Please enter a valid distance between 1 and 50")

      else:
      print("Have you tried digits?")

      elif car_type == "no":
      print("Please redo")

      else:
      print("Please enter a valid answer")

      elif seats == "exit":
      break

      elif seats < 1 or seats > 12:
      print("Enter within the given range")



      elif (not int(seats) > 0) or (not int(seats) < 13) or (not seats == "exit"):
      print("========================================")


      if clarify == "no":
      break

      else:
      continue

      else:
      print("Please redo n=======================================")

      elif count == int(24):
      count += 1
      print("You have reached the maximum amount of list inputs!")

      elif menu == "2":
      print("Saloon: " + ' '.join(saloon) + "nPeople carrier: " + ' '.join(people_car) + "nMini van: " + ' '.join(mini))
      print("========================================")

      elif menu == "3":

      print("Riders: " + repr(total_seats) + "nCost: RM" + repr(total_cost))

      def calc(a):
      avg_cost = float(a) / 100
      return avg_cost * 7.4

      final_sln = float(calc(sln_distance))
      final_ppl = float(calc(ppl_distance))
      final_mini = float(calc(mini_distance))

      print("Saloon fuel cost: RM" + repr(round(final_sln, 2)))
      print("People carrier fuel cost: RM" + repr(round(final_ppl, 2)))
      print("Mini van fuel cost: RM" + repr(round(final_mini, 2)))
      print("========================================")

      elif menu == "4":
      prompt = input("Exit program? (yes/no)")
      if prompt == "yes":
      exit()
      else:
      print("Command canceled")
      continue






      python python-3.x calculator






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago









      200_success

      126k14147408




      126k14147408










      asked 2 hours ago









      Skryptix

      386




      386




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          To start off, I suggest you split the chunk of if/elif statements into individual functions. By doing this, it'll be easier for someone reader (such as your teacher) to be able to tell what each part of the code is doing. It's also important because it'll help you remember your code when you come back to look at it.



          The upper level if statements, which are checking for seats, the code underneath them can be split into individual functions. Doing this would greatly improve your code.



          Good luck on your assignment!






          share|improve this answer




















          • Furthermore, functions would allow you to test the code, as stated in the requirements.
            – 200_success
            1 hour ago










          • Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
            – Skryptix
            1 hour ago










          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f206771%2ftaxi-fare-calculator-trip-recorder-and-fuel-calculator%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          To start off, I suggest you split the chunk of if/elif statements into individual functions. By doing this, it'll be easier for someone reader (such as your teacher) to be able to tell what each part of the code is doing. It's also important because it'll help you remember your code when you come back to look at it.



          The upper level if statements, which are checking for seats, the code underneath them can be split into individual functions. Doing this would greatly improve your code.



          Good luck on your assignment!






          share|improve this answer




















          • Furthermore, functions would allow you to test the code, as stated in the requirements.
            – 200_success
            1 hour ago










          • Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
            – Skryptix
            1 hour ago














          up vote
          3
          down vote













          To start off, I suggest you split the chunk of if/elif statements into individual functions. By doing this, it'll be easier for someone reader (such as your teacher) to be able to tell what each part of the code is doing. It's also important because it'll help you remember your code when you come back to look at it.



          The upper level if statements, which are checking for seats, the code underneath them can be split into individual functions. Doing this would greatly improve your code.



          Good luck on your assignment!






          share|improve this answer




















          • Furthermore, functions would allow you to test the code, as stated in the requirements.
            – 200_success
            1 hour ago










          • Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
            – Skryptix
            1 hour ago












          up vote
          3
          down vote










          up vote
          3
          down vote









          To start off, I suggest you split the chunk of if/elif statements into individual functions. By doing this, it'll be easier for someone reader (such as your teacher) to be able to tell what each part of the code is doing. It's also important because it'll help you remember your code when you come back to look at it.



          The upper level if statements, which are checking for seats, the code underneath them can be split into individual functions. Doing this would greatly improve your code.



          Good luck on your assignment!






          share|improve this answer












          To start off, I suggest you split the chunk of if/elif statements into individual functions. By doing this, it'll be easier for someone reader (such as your teacher) to be able to tell what each part of the code is doing. It's also important because it'll help you remember your code when you come back to look at it.



          The upper level if statements, which are checking for seats, the code underneath them can be split into individual functions. Doing this would greatly improve your code.



          Good luck on your assignment!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Faraz

          1636




          1636











          • Furthermore, functions would allow you to test the code, as stated in the requirements.
            – 200_success
            1 hour ago










          • Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
            – Skryptix
            1 hour ago
















          • Furthermore, functions would allow you to test the code, as stated in the requirements.
            – 200_success
            1 hour ago










          • Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
            – Skryptix
            1 hour ago















          Furthermore, functions would allow you to test the code, as stated in the requirements.
          – 200_success
          1 hour ago




          Furthermore, functions would allow you to test the code, as stated in the requirements.
          – 200_success
          1 hour ago












          Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
          – Skryptix
          1 hour ago




          Thanks for your advice! I'll test it out later, BTW thanks for helping me edit my post XD
          – Skryptix
          1 hour ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f206771%2ftaxi-fare-calculator-trip-recorder-and-fuel-calculator%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          Installing NextGIS Connect into QGIS 3?

          One-line joke