Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args, int num6)
  8. {
  9. Console.WriteLine("Welcome!");
  10. Console.WriteLine("You are asked to answer two questions correctly");
  11.  
  12. int maxAttempts = 3;
  13. bool IsRightAnswer = false;
  14. int attCount = 0;
  15. Console.WriteLine("You will be given {0} Attempts for each question", maxAttempts);
  16.  
  17.  
  18. while (attCount < maxAttempts && !IsRightAnswer)
  19. {
  20. int num1 = 5;
  21. int num2 = 33;
  22.  
  23.  
  24. Console.WriteLine("How much is {0} + {1} ?", num1, num2);
  25.  
  26. string answer = Console.ReadLine();
  27.  
  28. IsRightAnswer = (num1 + num2 == int.Parse(answer));
  29. if (IsRightAnswer)
  30. {
  31. Console.WriteLine("Correct! Moving to the next question");
  32.  
  33. }
  34. else
  35. {
  36. Console.WriteLine("WRONG! You have {0} attempts left", attCount);
  37.  
  38. attCount++;
  39. }
  40.  
  41. while (attCount < maxAttempts && !IsRightAnswer)
  42. {
  43. int num3 = 10;
  44. int num4 = 35;
  45.  
  46. Console.WriteLine("How much is {0} - {1} ?", num4, num3);
  47.  
  48. string answer2 = Console.ReadLine();
  49. IsRightAnswer = (num4 - num3 == int.Parse(answer2));
  50. if (IsRightAnswer)
  51. {
  52. Console.WriteLine("Congratulations! You beat the game!");
  53. }
  54. else
  55. {
  56. Console.WriteLine("Wrong! You have {0} Attemps left", attCount);
  57. attCount++;
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement