repl.it
@kironroy/

tipcalc

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;

class MainClass 
{
  public static void Main (string[] args) {
    Console.WriteLine($"\nEnter the meal cost");
    double meal_cost = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine($"\nYou entered {meal_cost} as the meal cost");

    Console.WriteLine($"\nEnter the tip % as a whole number");
    int tip_percent = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine($"\nYou entered a tip percent of: {tip_percent}% ");

    Console.WriteLine($"\nEnter the tax % as a whole number");
    int tax_percent = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine($"\nYou entered a tax percent of: {tax_percent}%");

    var totalMealCost = TotalMealCost(meal_cost, tip_percent, tax_percent);
    
    Console.WriteLine("\n------------------------------------------");
    Console.WriteLine($"Your total bill amount is: {totalMealCost}");
    Console.WriteLine("------------------------------------------");


  }

    private static double TotalMealCost(double meal_cost, int tip_percent, int tax_percent)
        {

          double tip = meal_cost * (tip_percent / 100d);
          double tax = meal_cost * (tax_percent / 100d);
          double totalCost = meal_cost + tip + tax;


          //return Math.Round(totalCost);
          return totalCost;

        }
}