Question
C# engage here is the question: Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One should accept a meal price and
C# engage here is the question:
Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo.
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).
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).
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.00. Tip percent: 0.20 Tip in dollars: $6.00. Total bill $36.00
In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfomethod. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));
here is my code. it says it is wrong
using System;
using static System.Console;
using System.Globalization;
// first function takes meal price as double and tip also as double as a percent of meal price
static void DisplayTipInfo(double meal_price , double tip){
double tip_val= meal_price * tip;
Console.WriteLine("Meal Price : $"+ meal_price.ToString("F")+ " Tip Percent : $"+tip.ToString("F"));
Console.WriteLine("Total Price : $"+ (meal_price+tip_val).ToString("F")+" Tip: $"+tip_val.ToString("F"));
}
// second function takes meal price as double and tip value also as double
static void DisplayTipInfo(double meal_price, int tip){
Console.WriteLine("Meal Price : $"+ meal_price.ToString("F")+ " Tip Val : $"+tip.ToString("F"));
Console.WriteLine("Total Price : $"+ (meal_price+tip).ToString("F"));
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started