-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
57 lines (43 loc) · 1.16 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Diagnostics;
class Test
{
static void Main()
{
Console.Clear();
Console.WriteLine("Enter to start!");
var start = Console.ReadLine();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
int correct = 0;
int wrong = 0;
int i = 0;
while (i < 5)
{
Random randomGenerator = new Random();
int f1 = randomGenerator.Next(0,10);
int f2 = randomGenerator.Next(0,10);
int sum = f1 * f2;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(f1 + "*" + f2);
var input = Console.ReadLine();
int result = Int32.Parse(input);
if (sum == result) {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Rätt!");
correct++;
} else {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Fel!");
wrong++;
}
i++;
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Antal rätt: " + correct);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Antal fel: " + wrong);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Time elapsed: {0:hh\\:mm\\:ss}", stopwatch.Elapsed);
}
}