public static void GuessingGame() { Random random = new Random(); int rightNumber = random.Next(1, 99); Console.WriteLine("I am thinking of a number between 1-99. Which one?"); int Guess = Exercise1.ReadInt(""); int ComputerGuessMax = 99; int ComputerGuessMin = 1; int ComputerGuess = random.Next(ComputerGuessMin, ComputerGuessMax); while (Guess != rightNumber) { if (Guess < rightNumber) { Console.WriteLine("No its higher than " + Guess + "."); } if (Guess > rightNumber) { Console.WriteLine("No, its lower than " + Guess + "."); //Guess = Exercise1.ReadInt(""); } if (ComputerGuess < rightNumber) { Console.WriteLine("Computer think its " + ComputerGuess + " But its higher. "); ComputerGuessMin = ComputerGuess; ComputerGuess = random.Next(ComputerGuessMin, ComputerGuessMax); } if (ComputerGuess > rightNumber) { Console.WriteLine("Computer think its " + ComputerGuess + " But its lower. "); ComputerGuessMax = ComputerGuess; ComputerGuess = random.Next(ComputerGuessMin, ComputerGuessMax); } if (ComputerGuess == rightNumber) { Console.WriteLine("Well done Mr Roboto! You beat the human, the number is " + rightNumber); } Guess = Exercise1.ReadInt(""); } Console.WriteLine("Well done! I was thinking of " + rightNumber); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Write a number"); int x = Exercise1.ReadInt(""); Console.WriteLine("First Number is " + x); Console.WriteLine("Type another number: "); int y = Exercise1.ReadInt("Type another number: "); Console.WriteLine("Second Number is " + y); Console.WriteLine($"{x} + {y} = {x + y}"); Exercise2.LeapYear(""); Exercise3.PalindromeCheck(""); Console.WriteLine("Press Key to initiate FizzBuzz"); Console.ReadLine(); Exercise4.FizzBuzz(); Console.WriteLine("Press Key to initiate Guessing Game"); Console.ReadLine(); Exercise5.GuessingGame(); Console.ReadLine(); }
public static void LeapYear(string line) { // Checing the leap year between 2000 to 2019 Console.WriteLine("Write a Year above 0 "); int x = Exercise1.ReadInt(line); Console.WriteLine("Write another Year above " + x); int z = Exercise1.ReadInt(line); for (int y = x; y <= z; y++) { if (DateTime.IsLeapYear(y)) { Console.WriteLine("{0} *", y); } else { Console.WriteLine("{0}", y); } } Console.WriteLine("LeapYears!!!!"); }