Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.21 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.                 Random rnd = new Random();
  22.                
  23.                 int sum1 = rnd.Next(1, 11);
  24.                 int sum2 = rnd.Next(1, 11);
  25.                 int answer;
  26.  
  27.                 int option = rnd.Next(1, 4);
  28.                 int question = option;
  29.                 string question2 = "";
  30.                 if (question == 1)
  31.                 {
  32.                     question2 = "+";
  33.                 }
  34.                 if (question == 2)
  35.                 {
  36.                     question2 = "X";
  37.                 }
  38.                 if (question == 3)
  39.                 {
  40.                     question2 = "-";
  41.                 }
  42.  
  43.                 Console.WriteLine("Asnwer this question!");
  44.                 Console.WriteLine("What is:" + sum1 + " " + question2 + " " + sum2);
  45.                 answer = Convert.ToInt32(Console.ReadLine());
  46.  
  47.  
  48.  
  49.                 if (option == 1)
  50.                 {
  51.                     if (answer == sum1 + sum2)
  52.                     {
  53.                         Console.WriteLine("Well done bro!");
  54.                         correct++;
  55.                     }
  56.                     else
  57.                     {
  58.                         Console.WriteLine("Wrong! keep practicing bro!");
  59.                         wrong++;
  60.                     }
  61.                 }
  62.                 else if (option == 2)
  63.                 {
  64.                     if (answer == sum1 * sum2)
  65.                     {
  66.                         Console.WriteLine("Well done bro!");
  67.                         correct++;
  68.                     }
  69.                     else
  70.                     {
  71.                         Console.WriteLine("Wrong! keep practicing bro!");
  72.                         Console.Beep()
  73.                         wrong++;
  74.                     }
  75.                 }
  76.                 else if (option == 3)
  77.                 {
  78.                     if (answer == sum1 - sum2)
  79.                     {
  80.                         Console.WriteLine("Well done bro!");
  81.                         correct++;
  82.                     }
  83.                     else
  84.                     {
  85.                         Console.WriteLine("Wrong! keep practicing bro!");
  86.                         Console.Beep();
  87.                         wrong++;
  88.                     }
  89.                 }
  90.                 Console.Clear();
  91.                
  92.             }
  93.             Console.WriteLine("you got: "+ correct + " correct and: " + wrong + "wrong");
  94.             Console.WriteLine("do you want to exit? \n then type yes");
  95.              
  96.             string yes = Console.ReadLine();
  97.            
  98.             if (yes == "yes")
  99.             { System.Environment.Exit(1); }
  100.             Console.ReadKey();
  101.             else { goto start; }
  102.         }
  103.                
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement