-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking c# code for number gen .txt
50 lines (37 loc) · 1.27 KB
/
working c# code for number gen .txt
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
actual code for rando gen
using System;
namespace random_number_generator
{
internal class Program
{
static void Main(string[] args)
{
//Declaration
Random number = new Random();
int randomNumber;
int input;
int count;
// Generate a random number within the range 1 to 5
randomNumber = number.Next(1, 6);
Console.WriteLine("guess a number between 1 to 5 ");
input = Convert.ToInt32(Console.ReadLine());
//loop used to prompt question 4 times and exits once count is met
for (count = 0; count < 4 ; count ++ )
if ( input == randomNumber )
{
Console.WriteLine("Correct!");
Console.ReadLine();
break;
}
else
{
Console.WriteLine("Incorrect, better luck next time.");
Console.ReadLine();
Console.WriteLine("guess a number between 1 to 5 ");
input = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Goodbye");
Console.ReadLine();
}
}
}