This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
87 lines (84 loc) · 2.89 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
namespace simple_survey_example
{
class Program
{
public static readonly string[] QUESTIONS = {
"example question 1",
"example question 2",
"example question 3",
"example question 4",
"example question 5"
};
private static List<byte[]> responses = new List<byte[]>();
static void Main(string[] _)
{
Console.WriteLine("Welcome to the simple survey program!");
bool exit = false;
while (!exit)
{
Console.Write("(R)eport, (Q)uestionnaire, (E)xit? ");
string menu_response = Console.ReadLine();
switch (menu_response.ToUpper())
{
case "R":
ShowReport();
break;
case "Q":
ShowQuestionnaire();
break;
case "E":
exit = true;
break;
default:
throw new Exception("Invalid Command");
}
}
}
static void ShowReport()
{
Console.WriteLine("1\t|2\t|3\t|4\t|5\t|6\t|7\t|8\t|9\t|10\t|");
for (int i = 0; i < QUESTIONS.Length; i++)
{
byte[] ratings_total = new byte[10];
foreach (var ratings in responses)
{
ratings_total[ratings[i] - 1] ++;
}
for (int j = 0; j < ratings_total.Length; j++)
{
Console.Write("{0}\t|", ratings_total[j]);
}
Console.WriteLine();
}
}
static void ShowQuestionnaire()
{
byte[] ratings = new byte[QUESTIONS.Length];
Console.WriteLine("Rate these questions from 1-10 (1 being less important), press a key to continue");
Console.ReadKey();
for (int i = 0; i < QUESTIONS.Length; i++)
{
Console.WriteLine("{0}. {1}", i + 1, QUESTIONS[i]);
while (true)
{
Console.Write("Enter rating 1-10: ");
string raw_rating = Console.ReadLine();
bool rating_valid = byte.TryParse(raw_rating, out byte rating);
if (rating_valid)
{
if (rating >= 1 && rating <= 10)
{
ratings[i] = rating;
break;
}
}
Console.WriteLine("Invalid Input!");
}
}
responses.Add(ratings);
Console.WriteLine("Thank you for your answers.");
}
}
}