Skip to content

Instantly share code, notes, and snippets.

@brockthebear
Created April 13, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brockthebear/9c736e6f90a826bc49b7fd2d827861e8 to your computer and use it in GitHub Desktop.
Save brockthebear/9c736e6f90a826bc49b7fd2d827861e8 to your computer and use it in GitHub Desktop.
import sys
def get_total_cost_of_meal():
# original meal price
meal_cost = float(sys.stdin.readline())
# tip percentage
tip_percent = int(sys.stdin.readline())
# tax percentage
tax_percent = int(sys.stdin.readline())
# Write your calculation code here
# calculate tip
tip = meal_cost * (tip_percent / 100)
# caclulate tax
tax = meal_cost * (tax_percent / 100)
# cast the result of the rounding operation to an int and save it as total_cost
total_cost = int(round(meal_cost + tip + tax))
return str(total_cost)
# Print your result
print("The total meal cost is " + get_total_cost_of_meal() + " dollars.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment