-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (32 loc) · 1.05 KB
/
Program.cs
File metadata and controls
46 lines (32 loc) · 1.05 KB
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
using System;
namespace GuessGame
{
class Program
{
static void Main(string[] args)
{
Random random = new Random();
int returnValue = random.Next(1,50);
int trial = 3;
Console.WriteLine("I am thinking of a number between 1-50. Can you guess what it is?");
while (Guess != returnValue)
{
Guess = Convert.ToInt32(Console.ReadLine());
if (Guess < returnValue)
{
Console.WriteLine("No, the number I am thinking of is higher than " + Guess + ". Can you guess again?");
}
else if (Guess > returnValue)
{
Console.WriteLine("No, the number I am thinking of is lower than " + Guess + ". Can you guess for the third time?");
}
else
{
Console.WriteLine("Yeahh! The answer was " + returnValue)
Console.ReadLine();
break;
}
}
}
}
}