-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (47 loc) · 1.54 KB
/
Program.cs
File metadata and controls
56 lines (47 loc) · 1.54 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
52
53
54
55
56
// See https://aka.ms/new-console-template for more information
using Practice;
var input = "";
//keep taking user input until user wants to exit
while (true)
{
//Write console write to take user choice
Console.WriteLine("Choose an option:");
Console.WriteLine("1. Reverse String");
Console.WriteLine("2.IsPalindrome");
Console.WriteLine("3.FindMax");
Console.WriteLine("c.Clear");
Console.WriteLine("9. Exit");
var choice = Console.ReadLine();
var result = "";
//use switch case to call respective method based on user choice
switch (choice)
{
case "1":
Console.WriteLine("Enter a String");
input = Console.ReadLine();
result = AlgorithmicQuestions.ReverseString(input); ;
break;
case "2":
Console.WriteLine("Enter a String");
input = Console.ReadLine();
result = AlgorithmicQuestions.IsPalindrome(input).ToString();
break;
case "3":
Console.WriteLine("Enter numbers separated by commas");
input = Console.ReadLine();
var numbers = input.Split(',').Select(int.Parse).ToArray();
result = AlgorithmicQuestions.FindMax(numbers).ToString();
break;
case "c":
Console.Clear();
continue;
case "9":
Environment.Exit(0);
break;
default:
Console.WriteLine("Invalid choice");
break;
}
Console.WriteLine($"Result {result}");
Console.ReadKey();
}