using System; namespace CSharpMultiplication { class Program { static void Main(string[] args) { try { //Declare two integer variables int valueOne; int valueTwo; // declare a const variable to hold the value that each number will be // multiplied by //Note: "const" specifies that the value of the field or the local variable cannot be modified. const int MULTIPLIER = 12; //Prompt the user to enter a number between 1 and 12 Console.WriteLine("Please enter a number between 1 and 12"); //Set the entered number to the variable 'valueOne' valueOne = int.Parse(Console.ReadLine()); //Check if the Number is between 1 AND 12: //Use && operator to determine whether the number entered //Note: The conditional-AND operator (&&) performs a //logical-AND of its bool operands, but only evaluates its second operand if necessary. if (valueOne > 0 && valueOne < 13) { //The number entered is between 1 and 12. The if block will be executed valueTwo = valueOne * MULTIPLIER; Console.WriteLine( valueOne + " x " + MULTIPLIER + " = " + valueTwo); } else { //The number is NOT between 1 and 12. The 'else' block will be executed Console.WriteLine( "You didn't enter a number between 1 and 12"); } } catch (FormatException) { //The user didn't enter a whole number //A formatException has been thrown. The catch block should be executed Console.WriteLine( "You didn't enter a whole number"); } Console.WriteLine("\nPress any key to exit"); Console.Read(); } } }