Advertisement
mess0011

u3_1

Oct 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 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 ConsoleApplication23
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Random a = new Random();
  14.             Random b = new Random();
  15.             int correct_solution = 0;
  16.  
  17.             Console.WriteLine("The task is to solve 3 examples");
  18.  
  19.             for(int i=0; i<3; i++)
  20.             {
  21.                 int a1 = a.Next(1, 9);
  22.                 int b1 = b.Next(1, 9);
  23.                 int sum = a1 + b1;
  24.              
  25.                 Console.WriteLine("Pls caluclate the result!");
  26.                 Console.WriteLine("{0} + {1} = ", a1, b1);
  27.                 int sum1 = Convert.ToInt32(Console.ReadLine());
  28.  
  29.                 if(sum1 == sum)
  30.                 {
  31.                     Console.WriteLine(" {0} is correct", sum1);
  32.                     correct_solution++;
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine("the result is incorrect!");
  37.                     Console.WriteLine("the correct answer is {0}", sum);
  38.                 }
  39.             }
  40.             Console.WriteLine("you have {0} correct answers", correct_solution);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement