I am developing an app for a client. It should get some inputs from the console, like total meal price; plus, the second line should ask for the tip percentage. The third would ask for taxPercent.
I have the following code, but it fails one of two test cases.
When I enter 15.50 for mealCoast
, 15 percent for tip and 10% for tax, it passes the test case. However, if I enter 12.00 for mealCost
, 20 for tip% and 8 for tax percent, it fails to meet the test case requirements.
Here you can see my code sample.
double mealCoast = double.Parse(Console.ReadLine());
int tipPercent = int.Parse(Console.ReadLine());
int taxPercent = int.Parse(Console.ReadLine());
//Calculating %
tipPercent = Convert.ToInt16(mealCoast) * (tipPercent) / 100;
taxPercent = Convert.ToInt16(mealCoast) * (taxPercent) / 100;
int totalCast = Convert.ToInt16(mealCoast) + tipPercent + taxPercent;
Console.WriteLine("The total meal cost is {0} dollars.", totalCast);
Console.ReadKey();