In: Computer Science
C# Tip Calculator. I can't figure the code out for this assignment can I get some help
For this assignment, you'll create a simple tip calculator. Expected program flow:
Total for bill $10.00 with a 15% tip is $11.50
Note that the money values should be formatted using the correct currency, prefixed with the $ and rounded to 2 decimal places.
Here Iam providing the code and the output for the given problem
Code
Sample Output
Code
using System;
class Test{
static void Main() {
Console.WriteLine("Enter the bill total : "); //reading inputs from
user
double TotalBill = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the tip percentage : "); //reading the tip
Percentage
double Percentage = double.Parse(Console.ReadLine());
double tip = TotalBill * (Percentage/100.0); //calculating the
tip
double result = Math.Round((TotalBill + tip),2); //rounding to two
decimal places
string res = result.ToString("0.00"); //adds trail zero if the
result has 1 decimal place
Console.WriteLine("Total for bill $"+TotalBill+" with a
"+Percentage+"% tip is $"+res);
}
}