We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 2: Operators
Day 2: Operators
+ 0 comments double tip = (meal_cost / 100) * tip_percent; double tax = (meal_cost / 100) * tax_percent; double total_cost = (meal_cost + tip + tax); long round_total_cost = Math.round(total_cost); System.out.println(round_total_cost);
+ 0 comments 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 rounded_cost = round(total_cost) print(rounded_cost)
Reading input values
meal_cost = float(input()) tip_percent = int(input()) tax_percent = int(input())
Calling the function
solve(meal_cost, tip_percent, tax_percent)
+ 0 comments double tip = (meal_cost / 100) * tip_percent; double tax = (tax_percent / 100) * meal_cost; double total_cost = meal_cost + tip + tax; long rounded_total_cost = Math.round(total_cost); System.out.println(rounded_total_cost);
+ 0 comments Simple C++ Solution: cout << (int) round((meal_cost + (meal_cost/100 * tip_percent) + (meal_cost/100 * tax_percent)));
+ 1 comment if __name__ == '__main__': meal_cost = float(input().strip()) tip_percent = int(input().strip()) tax_percent = int(input().strip()) print(meal_cost**2) print(tip_percent/100*meal_cost) print(tax_percent/100*meal_cost)
solve(meal_cost, tip_percent, tax_percent)
Load more conversations
Sort 3317 Discussions, By:
Please Login in order to post a comment