public static void Main()
int sumOfSquares = 0, count = 0, start = 1;
Console.WriteLine(" Looping Demo: Event & Counter Controlled\n");
Console.Write(" Enter the number of loops to perform (2 - 10): ");
inputString = Console.ReadLine();
if (int.TryParse(inputString, out count))
if (count >= 2 && count <= 10)
Console.WriteLine("ERROR: Not in range of 2-10 ... Please try again");
Console.WriteLine("ERROR: Not a number ... Please try again");
Console.Write(" Enter the number of loops to perform (2 - 10): ");
inputString = Console.ReadLine();
sumOfSquares += start * start;
Console.WriteLine("The sum of squares to {0} = {1}", count, sumOfSquares);
Console.Write("Do another (Y/N): ");
doAgain = char.ToUpper(char.Parse(Console.ReadLine()));
} while (doAgain == 'Y');
Console.WriteLine("\nThank you ... goodbye");