Guest User

Untitled

a guest
Aug 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // Boolean if user passes
  2. Boolean Userpassed;
  3. // Declares Answer Variable
  4. int answer = 6;
  5. // Asks user for a number
  6. Console.WriteLine("Enter a number between 1 and 10");
  7. // Displays Message
  8. Console.ReadLine();
  9. // Takes User Input as String
  10. string useranswer = Console.ReadLine();
  11. // Declares integer for actual integer
  12. int userinput;
  13. // User string parsed to Int
  14. userinput = Convert.ToInt32(Console.Read());
  15. // Displays Message
  16. Console.ReadLine();
  17. // Checks if input is equal to answer
  18. if (userinput == answer)
  19. {
  20. // User passes
  21. Console.WriteLine("Congratulations, you have passed");
  22.  
  23. }
  24. // Checks if input is greater than answer
  25. else
  26. if (userinput > answer)
  27. {
  28. // User Fails
  29. Console.WriteLine("The actual answer is less than what you entered");
  30. }
  31. // Checks if input is less than answer
  32. else
  33. if (userinput < answer)
  34. {
  35. // User Fails
  36. Console.WriteLine("The actual answer is greater than what you entered");
  37. }
  38. // Displays Message
  39. Console.ReadLine();
Add Comment
Please, Sign In to add comment