/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 304 - Problem 3: Magic Number (a) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static void Main(string[] args) { int number, guess = -1; Random r = new Random(); number = r.Next(1, 11); for (int i = 0; i < 5; i++) { if (i < 4) Console.Write("Trial number {0}/5, guess the number: ", i + 1); else Console.Write("LAST TRIAL! Guess the number: "); guess = int.Parse(Console.ReadLine()); if (guess == number) { Console.WriteLine("\n\n\t\t\tBRAVO, you win!"); break; } else if (guess > number) Console.WriteLine("Wrong answer, your guess is BIG\n"); else Console.WriteLine("Wrong answer, your guess is SMALL\n"); } if (guess != number) Console.WriteLine("\nGame Over, you lose :("); Console.ReadKey(); } } }