Guest User

Untitled

a guest
May 27th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace littleprofessor
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int akrai;
  13. int first;
  14. Random rnd = new Random();
  15.  
  16. Random num = new Random();
  17.  
  18. int correct=0;
  19. int answer = 0;
  20.  
  21.  
  22. Console.WriteLine("How many questions?");
  23. int questions;
  24. do
  25. {
  26. questions = int.Parse(Console.ReadLine());
  27. }
  28. while (questions < 1);
  29. Random num2 = new Random();
  30. Console.WriteLine("Choose level of difficulty from 1 to 3, 1 is easiest, 3 is hardest");
  31. int level=0;
  32. do
  33. {
  34. level = int.Parse(Console.ReadLine());
  35. }
  36. while ((level < 1) || (level > 3));
  37.  
  38. for (int i = 1; i <= questions; i++)
  39. {
  40. if (level == 1)
  41. {
  42.  
  43. akrai = rnd.Next(3);
  44. if (akrai==1)
  45. {
  46. first = num.Next(9) + 1;
  47. int second = num2.Next(9) + 1;
  48. Console.WriteLine(first + "+" + second + "=");
  49. correct = first + second;
  50. answer = int.Parse(Console.ReadLine());
  51. if (answer == correct)
  52. {
  53. Console.WriteLine("Correct!");
  54. }
  55. else
  56. {
  57. Console.WriteLine("Try again");
  58. answer = int.Parse(Console.ReadLine());
  59. if (answer == correct)
  60. {
  61. Console.WriteLine("Correct!");
  62. }
  63. else
  64. {
  65. Console.WriteLine("Wrong! " + first + "+" + second + "=" + correct);
  66. }
  67.  
  68. }
  69. }
  70. if (akrai==2)
  71. {
  72. int second = num2.Next(9) + 1;
  73. int first = num.Next(9) + second;
  74. Console.WriteLine(first + "-" + second + "=");
  75. correct = first - second;
  76. answer = int.Parse(Console.ReadLine());
  77. if (answer == correct)
  78. {
  79. Console.WriteLine("Correct!");
  80. }
  81. else
  82. {
  83. Console.WriteLine("Try again");
  84. answer = int.Parse(Console.ReadLine());
  85. if (answer == correct)
  86. {
  87. Console.WriteLine("Correct!");
  88. }
  89. else
  90. {
  91. Console.WriteLine("Wrong! " + first + "-" + second + "=" + correct);
  92. }
  93.  
  94. }
  95. }
  96. if (akrai==3)
  97. {
  98. int second = num2.Next(9) + 1;
  99. int first = num.Next(9) + 1;
  100. Console.WriteLine(first + "*" + second + "=");
  101. correct = first * second;
  102. answer = int.Parse(Console.ReadLine());
  103. if (answer == correct)
  104. {
  105. Console.WriteLine("Correct!");
  106. }
  107. else
  108. {
  109. Console.WriteLine("Try again");
  110. answer = int.Parse(Console.ReadLine());
  111. if (answer == correct)
  112. {
  113. Console.WriteLine("Correct!");
  114. }
  115. else
  116. {
  117. Console.WriteLine("Wrong! " + first + "*" + second + "=" + correct);
  118. }
  119.  
  120. }
  121. }
  122. if (akrai == 0)
  123. {
  124. do
  125. {
  126. int second = num2.Next(9) + 1;
  127. int first = num.Next(9) + second;
  128. }
  129. while (num1%num2!=0);
  130. }
  131.  
  132. Console.WriteLine(first + "-" + second + "=");
  133. correct = first - second;
  134. answer = int.Parse(Console.ReadLine());
  135. if (answer == correct)
  136. {
  137. Console.WriteLine("Correct!");
  138. }
  139. else
  140. {
  141. Console.WriteLine("Try again");
  142. answer = int.Parse(Console.ReadLine());
  143. if (answer == correct)
  144. {
  145. Console.WriteLine("Correct!");
  146. }
  147. else
  148. {
  149. Console.WriteLine("Wrong! " + first + "-" + second + "=" + correct);
  150. }
  151.  
  152. }
  153. }
  154. akrai = 2;
  155.  
  156. }
  157. if (level == 2)
  158. {
  159. }
  160. if (level == 3)
  161. {
  162. }
  163. }
  164.  
  165. }
  166. }
  167. }
Add Comment
Please, Sign In to add comment