Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace program
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.         start:
  14.             Console.WriteLine("How many questions do you wanna answer");
  15.             int a = Convert.ToInt32(Console.ReadLine());
  16.             Console.Clear();
  17.             int wrong = 0;
  18.             int correct = 0;
  19.             for (int i = 0; i < a; i++)
  20.             {
  21.  
  22.                 Random rnd = new Random();
  23.  
  24.                 int sum1 = rnd.Next(1, 11);
  25.                 int sum2 = rnd.Next(1, 11);
  26.                 int answer;
  27.  
  28.                 int option = rnd.Next(1, 4);
  29.                 int question = option;
  30.                 string question2 = "";
  31.                 if (question == 1)
  32.                 {
  33.                     question2 = "+";
  34.                 }
  35.                 if (question == 2)
  36.                 {
  37.                     question2 = "X";
  38.                 }
  39.                 if (question == 3)
  40.                 {
  41.                     question2 = "-";
  42.                 }
  43.  
  44.                 Console.WriteLine("Asnwer this question!");
  45.                 Console.WriteLine("What is:" + sum1 + " " + question2 + " " + sum2);
  46.                 answer = Convert.ToInt32(Console.ReadLine());
  47.  
  48.  
  49.  
  50.                 if (option == 1)
  51.                 {
  52.                     if (answer == sum1 + sum2)
  53.                     {
  54.                         Console.WriteLine("Well done bro!");
  55.                         correct++;
  56.                     }
  57.                     else
  58.                     {
  59.                         Console.WriteLine("Wrong! keep practicing bro!");
  60.                         wrong++;
  61.                     }
  62.                 }
  63.                 else if (option == 2)
  64.                 {
  65.                     if (answer == sum1 * sum2)
  66.                     {
  67.                         Console.WriteLine("Well done bro!");
  68.                         correct++;
  69.                     }
  70.                     else
  71.                     {
  72.                         Console.WriteLine("Wrong! keep practicing bro!");
  73.                         Console.Beep();
  74.                         wrong++;
  75.                     }
  76.                 }
  77.                 else if (option == 3)
  78.                 {
  79.                     if (answer == sum1 - sum2)
  80.                     {
  81.                         Console.WriteLine("Well done bro!");
  82.                         correct++;
  83.                     }
  84.                     else
  85.                     {
  86.                         Console.WriteLine("Wrong! keep practicing bro!");
  87.                         Console.Beep();
  88.                         wrong++;
  89.                     }
  90.                 }
  91.                 Console.Clear();
  92.  
  93.             }
  94.             Console.WriteLine("you got: " + correct + " correct and: " + wrong + "wrong");
  95.             Console.WriteLine("do you want to exit? \n then type yes");
  96.  
  97.             string yes = Console.ReadLine();
  98.  
  99.             if (yes == "yes")
  100.             {
  101.                 System.Environment.Exit(1);
  102.             }
  103.                 else { goto start; }
  104.             Console.ReadKey();
  105.         }
  106.  
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement