- You will run your visual studio 2010/2012/2013/2015 or above
- New project Create as Visual C# and select console Application then click OK .
Then You can write those code in Namespace ...{ //Code here }
Code :
class Program
{
static void Main(string[] args)
{
int TotalCoffeCost = 0;
Start:
Console.WriteLine("Please Seleect Your Coffe Size : \n1 - Small \n2 - Meduim \n3 - Large ");
int UserChoise = int.Parse(Console.ReadLine());
switch (UserChoise)
{
case 1:
TotalCoffeCost += 10; //Coffee Price
break;
case 2:
TotalCoffeCost += 20; //Coffee Price
break;
case 3:
TotalCoffeCost += 30; //Coffee Price
break;
default:
Console.WriteLine("Your choise {0} is invaid us", UserChoise);
goto Start;
}
Decide:
Console.WriteLine("Do you buy another coffe - YES or NO?");
string UserDessition = Console.ReadLine();
switch (UserDessition.ToUpper())
{
case "YES":
goto Start;
case "NO":
break;
default:
Console.WriteLine("Your Choise {0} is invalid, please try again.");
goto Decide;
}
Console.WriteLine("Thanks you for shopping us.");
Console.WriteLine("Your Bill Amount = {0}", TotalCoffeCost);
Console.ReadLine();
}
}
Then Build Your Project and Run Your Console Application .
- New project Create as Visual C# and select console Application then click OK .
Then You can write those code in Namespace ...{ //Code here }
Code :
class Program
{
static void Main(string[] args)
{
int TotalCoffeCost = 0;
Start:
Console.WriteLine("Please Seleect Your Coffe Size : \n1 - Small \n2 - Meduim \n3 - Large ");
int UserChoise = int.Parse(Console.ReadLine());
switch (UserChoise)
{
case 1:
TotalCoffeCost += 10; //Coffee Price
break;
case 2:
TotalCoffeCost += 20; //Coffee Price
break;
case 3:
TotalCoffeCost += 30; //Coffee Price
break;
default:
Console.WriteLine("Your choise {0} is invaid us", UserChoise);
goto Start;
}
Decide:
Console.WriteLine("Do you buy another coffe - YES or NO?");
string UserDessition = Console.ReadLine();
switch (UserDessition.ToUpper())
{
case "YES":
goto Start;
case "NO":
break;
default:
Console.WriteLine("Your Choise {0} is invalid, please try again.");
goto Decide;
}
Console.WriteLine("Thanks you for shopping us.");
Console.WriteLine("Your Bill Amount = {0}", TotalCoffeCost);
Console.ReadLine();
}
}
Then Build Your Project and Run Your Console Application .
0 comments:
Post a Comment