sorry i am very very new in programming.
My question is at switch statemnt if user type different of 1,2 or 3 i dont want to break but i want to start from beginning asking user again to type 1, 2 or 3, i know how to do with goto statemend, but i have read that is not prefered to use that statement.
Second question: is that right if i use multiple do while loops inside one class. please help and sorry about my english it is my second language.
class Program
{
static void Main(string[] args)
{
string secondchoice = "";
int userchoice;
int TotalCost = 0; ;
do
{
Console.WriteLine("1-Small, 2-Medium, 3-Large");
userchoice = int.Parse(Console.ReadLine());
switch (userchoice)
{
case 1:
TotalCost += 1;
break;
case 2:
TotalCost += 2;
break;
case 3:
TotalCost += 3;
break;
default:
Console.WriteLine("Your choice is invalid");
break;
}
if (userchoice == 1)
{
Console.WriteLine("Small Caffe");
}
else if (userchoice == 2)
{
Console.WriteLine("Medium");
}
else if (userchoice == 3)
{
Console.WriteLine("Big");
}
else
Console.WriteLine("Invalid choice");
do
{
Console.WriteLine("Anything else say yes or no");
secondchoice = Console.ReadLine();
if (secondchoice != "yes" && secondchoice != "no")
{
Console.WriteLine("Invalid choice, try again say yes or no");
}
}
while (secondchoice != "yes" && secondchoice != "no");
}
while (secondchoice == "yes");
Console.WriteLine("Thank you for shooping with us");
Console.WriteLine("Total =" + TotalCost);
}
}
}