Question: c# cengage mindtap Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One should accept a meal price and a tip as
c# cengage mindtap
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")));
it keeps saying my code is wrong. i have asked 3 chegg helpers and everyone has given me the wrong answer all day. its due by 1159 central.
this is my code it says this error every time.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Globalization;
namespace Rextester
{
public class Program
{
public static void DisplayTipInfo(double price,double tipRate){
Console.WriteLine("DOUBLE METHOD");
Console.WriteLine("Meal price: {0}\t Tip percent: {1} ",price.ToString("C",CultureInfo.GetCultureInfo("en-US")),
tipRate.ToString("C",CultureInfo.GetCultureInfo("en-US")));
double tipAmount=price*tipRate;
double total=price+tipAmount;
Console.WriteLine("Tip in Dollars: {0}\t Total bill: {1} ",tipAmount.ToString("C",CultureInfo.GetCultureInfo("en-US")),
total.ToString("C",CultureInfo.GetCultureInfo("en-US")));
}
public static void DisplayTipInfo(double price,int tipRate){
Console.WriteLine("INT METHOD");
Console.WriteLine("Meal price: {0}\t Tip percent: {1} ",price.ToString("C",CultureInfo.GetCultureInfo("en-US")),
tipRate.ToString("C",CultureInfo.GetCultureInfo("en-US")));
double tipAmount=price*tipRate;
double total=price+tipAmount;
Console.WriteLine("Tip in Dollars: {0}\t Total bill: {1} ",tipAmount.ToString("C",CultureInfo.GetCultureInfo("en-US")),
total.ToString("C",CultureInfo.GetCultureInfo("en-US")));
}
public static void Main(string[] args)
{
DisplayTipInfo(30,0.2);
DisplayTipInfo(30,2);
}
}
}
here is the error it gave me:
Compilation failed: 1 error(s), 1 warnings NtTest7896d51b.cs(6,1): warning CS0105: The using directive for `System' appeared previously in this namespace NtTest7896d51b.cs(22,9): error CS0103: The name `TipCalculation' does not exist in the current context
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
