-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday-2-operators.py
36 lines (25 loc) · 1.25 KB
/
day-2-operators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# https://www.hackerrank.com/challenges/30-operators/problem
# Task
# Given the
# meal price (base cost of a meal),
# tip percent (the percentage of the meal price being added as tip), and
# tax percent (the percentage of the meal price being added as tax) for a meal,
# find and print the meal's total cost.
# Note: Be sure to use precise values for your calculations, or you may end up with an incorrectly rounded result!
# Input Format
# There are 3 lines of numeric input:
# The first line has a double, mealCost (the cost of the meal before tax and tip).
# The second line has an integer, tipPercent (the percentage of mealCost being added as tip).
# The third line has an integer, taxPercent (the percentage of mealCost being added as tax).
# Output Format
# Print The total meal cost is totalCost dollars., where totalCost is the rounded integer result of
# the entire bill (mealCost with added tax and tip).
import sys
if __name__ == "__main__":
meal_cost = float(input().strip())
tip_percent = int(input().strip())
tax_percent = int(input().strip())
tip = meal_cost * tip_percent / 100
tax = meal_cost * tax_percent / 100
total_cost = round(meal_cost + tip + tax)
print('The total meal cost is {} dollars.'.format(str(total_cost)))