Need help with this in C# TipCalculation.cs Instructions 1sing static System.Con
ID: 3703107 • Letter: N
Question
Need help with this in C#
TipCalculation.cs Instructions 1sing static System.Console 2 class TipCalculation 3 Create a program named TipCalculation that includes two overloaded methods named 4 static void Main) DisplayTipInfo. // Write your main here One should accept a meal price and a tip as doubles (for example, 30.00 and 0.20, where 0.20 represents a 20 percent tip) 7 8 9 10 public static void DisplayTipInfo(double price, double tipRate) The other should accept a meal price as a double and a tip amount as an integer (for example, 30.00 and 5, where 5 represents a $5 tip) 12 public static void DisplayTipInfo(double price, int tipInDollars) 13 14 15 16 Each method displays the meal price, the tip as a percentage of the meal price, the tip in dollars, and the total of the meal plus the tip Include a Main) method that demonstrates each method For example if the input meal price is 30.00 and the tip is 0.20, the output should be Meal price : $30.08. Tip Percent : 8.29 Tip in dollars: $6.00. Total bill $36.00 Run Code Test GradeExplanation / Answer
using System;
class TipCalculation {
static void Main() {
Console.Write("Meal price: $");
double price = Convert.ToDouble(Console.ReadLine());
Console.Write("Tip percent: ");
double tipRate = Convert.ToDouble(Console.ReadLine());
DisplayTipInfo(price, tipRate);
}
public static void DisplayTipInfo(double price, double tipRate) {
Console.WriteLine(" Tip in dollars: $ " + (price * tipRate).ToString ("#.##") + ". Total bill $" + (price + (price * tipRate)).ToString ("#.##"));
}
public static void DisplayTipInfo(double price, int tipInDollars) {
Console.WriteLine(" Tip in dollars: $ " + tipInDollars.ToString ("#.##") + ". Total bill $" + (price + tipInDollars).ToString ("#.##"));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.