Hello,
When I execute the code below by pressing the F5 key, it somehow skips printing the last Console.WriteLine("Your total cost is {0}", TotalCost).
Can someone please explain why this happens and how do I go about getting it printed when executing my code?
When I execute the code below by pressing the F5 key, it somehow skips printing the last Console.WriteLine("Your total cost is {0}", TotalCost).
Can someone please explain why this happens and how do I go about getting it printed when executing my code?
C#:
using System;
class Program
{
static void Main()
{
bool result;
int UserChoice;
int TotalCost = 0;
string UserDecision;
do
{
UserDecision = string.Empty;
do
{
Console.WriteLine("Please select your coffee size: 1 - Small, 2 - Medium, 3 - Large");
result = int.TryParse(Console.ReadLine(), out UserChoice);
} while (result == false || (UserChoice != 1 && UserChoice != 2 && UserChoice != 3));
switch (UserChoice)
{
case 1:
TotalCost = TotalCost + 1;
break;
case 2:
TotalCost = TotalCost + 2;
break;
case 3:
TotalCost = TotalCost + 3;
break;
}
do
{
Console.WriteLine("Do you want to buy another coffee? - enter yes or no");
UserDecision = Console.ReadLine().ToLower();
} while (UserDecision != "yes" && UserDecision != "no");
} while (UserDecision == "yes");
Console.WriteLine("Your total cost is {0}", TotalCost);
}
}