Advertisement
minnera

#30daysofcode #day2

Sep 28th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. //https://www.hackerrank.com/challenges/30-operators/
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. class Solution {
  7.     static void Main(String[] args) {
  8.         /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
  9.         double mealCost = Double.Parse(Console.ReadLine());
  10.         double tipPercent = Double.Parse(Console.ReadLine());
  11.         double taxPercent = Double.Parse(Console.ReadLine());
  12.         double tip = mealCost * (tipPercent/100.0);
  13.         double tax = mealCost * (taxPercent/100.0);
  14.         double totalCost = mealCost + tip + tax;
  15.        
  16.         int rounded = (int)System.Math.Round(totalCost, 0, MidpointRounding.AwayFromZero);
  17.         Console.WriteLine("The total meal cost is " + rounded + " dollars.");
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement