using fCraft; public static void Main(string[] args) { CommandReader reader = new CommandReader(Console.In, Console.Out); Console.Write("Enter an integer value: "); int intValue = reader.NextInt(); Console.WriteLine("You entered {0}.", intValue); }
using fCraft; using System; public static void Main(string[] args) { CommandReader reader = new CommandReader(Console.In, Console.Out); Random rand = new Random(); int value = rand.Next(1, 101); Console.Write("Guess a number between 1 and 100: "); int guess = reader.NextInt(); while (guess != value) { if (guess > value) { Console.WriteLine("Too high!"); } else { Console.WriteLine("Too low!"); } Console.Write("Guess again: "); guess = reader.NextInt(); } Console.WriteLine("Congratulations, you guessed the number!"); }In this example, we use CommandReader to read the user's guess and provide feedback on whether the guess was too high or too low. The program uses a while loop to keep looping until the user guesses the correct value. Once the correct value is guessed, the program congratulates the user.