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.

Round the result to the nearest integer.

Solution

 1import math
 2import os
 3import random
 4import re
 5import sys
 6
 7#
 8# Complete the 'solve' function below.
 9#
10# The function accepts following parameters:
11#  1. DOUBLE meal_cost
12#  2. INTEGER tip_percent
13#  3. INTEGER tax_percent
14#
15
16def solve(meal_cost, tip_percent, tax_percent):
17    # Write your code here
18    tip_total = (meal_cost / 100) * tip_percent
19    tax_total = (tax_percent / 100) * meal_cost
20    total_bill = meal_cost + tip_total + tax_total
21    print(f"{round(total_bill)}")
22
23if __name__ == '__main__':
24    meal_cost = float(input().strip())
25
26    tip_percent = int(input().strip())
27
28    tax_percent = int(input().strip())
29
30    solve(meal_cost, tip_percent, tax_percent)
HackerRank | Day 2: Operators