Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.hackerrank.com/challenges/30-operators/
- using System;
- using System.Collections.Generic;
- using System.IO;
- class Solution {
- static void Main(String[] args) {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
- double mealCost = Double.Parse(Console.ReadLine());
- double tipPercent = Double.Parse(Console.ReadLine());
- double taxPercent = Double.Parse(Console.ReadLine());
- double tip = mealCost * (tipPercent/100.0);
- double tax = mealCost * (taxPercent/100.0);
- double totalCost = mealCost + tip + tax;
- int rounded = (int)System.Math.Round(totalCost, 0, MidpointRounding.AwayFromZero);
- Console.WriteLine("The total meal cost is " + rounded + " dollars.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement