HackerRank【30 Days of Code——day02】

Day 2: Operators

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!

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
    totalCost = meal_cost+ meal_cost*(tip_percent/100)+meal_cost*(tax_percent/100)
    totalCost = round(totalCost)
    print(totalCost)
if __name__ == '__main__':
    meal_cost = float(input())

    tip_percent = int(input())

    tax_percent = int(input())

    solve(meal_cost, tip_percent, tax_percent)

 

posted @ 2019-07-21 19:33  乱世有歌舞  阅读(104)  评论(0编辑  收藏  举报