HackerRank 30 days of coding – Day2

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!

Day2

Sample Input:


12.00
20
8
Sample Output:
15
 
Solution :
 
#!/bin/python

import math
import os
import random
import re
import sys

def solve(meal_cost, tip_percent, tax_percent):
     tip=meal_cost*tip_percent/100
     tax=meal_cost*tax_percent/100
     total_cost=meal_cost+tip+tax
     printint(round(total_cost))

if __name__ == '__main__':
     meal_cost = float(raw_input())
     tip_percent = int(raw_input())
     tax_percent = int(raw_input())
     solve(meal_cost, tip_percent, tax_percent)

Leave a Reply