p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Visual C# 2010 (http://p2p.wrox.com/forumdisplay.php?f=563)
-   -   Chapter 4, Exercise 2 Solution (http://p2p.wrox.com/showthread.php?t=87580)

 malie22001 May 19th, 2012 11:43 PM

Chapter 4, Exercise 2 Solution

In the book, the authors provided two solutions. They stated that the second solution is better thatn the first they provided. That made me wonder whether my solution is any better.

Code:

```static void Main(string[] args)         {             int num1, num2;             bool bothGreaterThan10;             do             {                 Console.Write("Enter your first number: ");                 num1 = Convert.ToInt32(Console.ReadLine());                 Console.Write("Enter your second number: ");                 num2 = Convert.ToInt32(Console.ReadLine());                 bothGreaterThan10 = ((num1 > 10) && (num2 > 10));                 if (!bothGreaterThan10)                 {                     Console.WriteLine("You entered {0} and {1}", num1, num2);                 }                 else                 {                     Console.WriteLine(@"Your both numbers are greater than 10.\n                                         Only one number can be greater than 10.");                 }             }             while (bothGreaterThan10);                                   Console.ReadKey();         }```