Post by Admin on Jun 3, 2014 21:58:35 GMT -5
using System;
class Program
{
static void Main()
{
string UserChoice = ""; // string UserChoice = string.Empty
do
{
Console.WriteLine("Please enter your target?");
int UserTarget = int.Parse(Console.ReadLine());
int Start = 0;
while (Start <= UserTarget)
{
Console.Write(Start + " ");
Start = Start + 2;
}
do
{
Console.WriteLine("Do you want to continue - Yes or No?");
UserChoice = Console.ReadLine().ToUpper();
if (UserChoice != "YES" && UserChoice != "NO")
{
Console.WriteLine("Invalid Choice, please say Yes or No");
}
} while (UserChoice != "YES" && UserChoice != "NO");
} while (UserChoice == "YES");
}
}
using System;
class Program
{
static void Main()
{
int TotalCoffeeCost = 0;
string UserDecision = string.Empty;
do
{
int UserChoice = -1
do
{
Console.WriteLine("Please select your coffee size: 1 - Small, 2 - Medium, 3 - Large");
UserChoice = int.Parse(Console.ReadLine());
switch (UserChoice)
{
case 1:
TotalCoffeeCost += 1;
break;
case 2:
TotalCoffeeCost += 2;
break;
case 3:
TotalCoffeeCost += 3;
break;
default:
Console.WriteLine("Your choice {0} is invalid", UserChoice);
break;
}
} while (UserChoice != 1 && UserChoice != 2 && UserChoice != 3);
do
{
Console.WriteLine("Do you want to buy another coffee - Yes or No?");
UserDecision = Console.ReadLine().ToUpper();
if (UserDecision != "YES" && UserDecision != "NO")
{
Console.WriteLine("Your choice {0} is invalid. Please try again...", UserDecision);
}
} while (UserDecision != "YES" && UserDecision != "NO");
} while (UserDecision.ToUpper() != "NO"
Console.WriteLine("Thank you for shopping with us");
Console.WriteLine("Bill Amount = {0}", TotalCoffeeCost);
}
}