-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitchselection.cs
More file actions
51 lines (44 loc) · 1.21 KB
/
Copy pathswitchselection.cs
File metadata and controls
51 lines (44 loc) · 1.21 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
45
46
47
48
49
50
51
using System;
class SwitchSelection
{
public static void Main()
{
string myInput;
int myInt;
begin:
Console.Write("Please enter a number between 1 and 3: ");
myInput = Console.ReadLine();
myInt = Int32.Parse(myInput);
// Switch with integer type
switch (myInt)
{
case 1:
Console.WriteLine("Your number is {0}.",myInt);
break;
case 2:
Console.WriteLine("Your number is {0}.",myInt);
break;
case 3:
Console.WriteLine("Your number is {0}.",myInt);
break;
default:
Console.WriteLine("Your number {0} is not between 1 and 3.",myInt);
break;
}
decide:
Console.Write("Type\"continue\"to go on or\"quit\"to stop: ");
myInput = Console.ReadLine();
// switch with string type
switch (myInput)
{
case "continue":
goto begin;
case "quit":
Console.WriteLine("bye.");
break;
defualt:
Console.WriteLine("Your input {0} is incorrect.",myInput);
goto decide;
}
}
}