Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Boolean if user passes
- Boolean Userpassed;
- // Declares Answer Variable
- int answer = 6;
- // Asks user for a number
- Console.WriteLine("Enter a number between 1 and 10");
- // Displays Message
- Console.ReadLine();
- // Takes User Input as String
- string useranswer = Console.ReadLine();
- // Declares integer for actual integer
- int userinput;
- // User string parsed to Int
- userinput = Convert.ToInt32(Console.Read());
- // Displays Message
- Console.ReadLine();
- // Checks if input is equal to answer
- if (userinput == answer)
- {
- // User passes
- Console.WriteLine("Congratulations, you have passed");
- }
- // Checks if input is greater than answer
- else
- if (userinput > answer)
- {
- // User Fails
- Console.WriteLine("The actual answer is less than what you entered");
- }
- // Checks if input is less than answer
- else
- if (userinput < answer)
- {
- // User Fails
- Console.WriteLine("The actual answer is greater than what you entered");
- }
- // Displays Message
- Console.ReadLine();
Add Comment
Please, Sign In to add comment