-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
153 lines (124 loc) · 3.26 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// See https://aka.ms/new-console-template for more information
double radius = 5;
double smlallside = 2 * radius;
double smallside = radius * math.Sqrt(2);
double smallarea = smallside * smallside;
double largside = smallside * math.Sqrt(2);
double largarea = largside * largside;
double areadifference = largarea - smallarea;
Console.WriteLine($"the difference is between the areas of the large and small squares:{areadifference}");
string[] input1 = { "@", "@", "@", "@", "@", "@" };
string[] input2 = { "x", "x", "x" };
string[] input3 = { "s", "s", "s" };
string[] input4 = { "@", "a", "@", "@", "@", "@" };
testjackpot(input1);
testjackpot(input2);
testjackpot(input3);
testjackpot(input4);
static void testjackpot(string[] input)
{
bool jackpot = checkjackpot(input);
if (jackpot)
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}
}
static bool checkjackpot(string[] input)
{
string firstsymbol = input[0];
foreach (string symbol in input)
{
if (symbol != firstsymbol)
{
return false;
}
}
return true;
}
int wins = 3;
int draws = 1;
int losses = 1;
int totalpoints = wins * 3 + draws * 1 + losses * 0;
Console.WriteLine(totalpoints);
int[][] hoursarray = {
new int[] { 8, 8, 8, 8, 8, 0, 0 },
new int[] { 8, 8, 8, 8, 8, 8, 0 },
new int[] { 4, 4, 4, 4, 4, 0, 4 },
new int[] { 5, 8, 8, 8, 8, 8, 8 }
};
foreach (var hours in hoursarray)
{
double totalincome = calculateincome(hours);
Console.WriteLine("input: " + string.Join(", ", hours) + " -> output: $" + totalincome);
}
static double calculateincome(int[] hours)
{
double totalincome = 0;
for (int i = 0; i < hours.Length; i++)
{
int dailyhours = hours[i];
if (i < 5)
{
if (dailyhours > 8)
{
totalincome += (8 * 10) + ((dailyhours - 8) * 15);
}
else
{
totalincome += dailyhours * 10;
}
}
else
{
totalincome += dailyhours * 20;
}
}
return totalincome;
}
int[] results1 = { 5, 8, 8, 9, 10 };
int improvementcount1 = countimprovements(results1);
Console.WriteLine("input 1: " + string.Join(", ", results1) + " -> output: " + improvementcount1);
int[] results2 = { 5, 5, 5, 5 };
int improvementcount2 = countimprovements(results2);
Console.WriteLine("input 2: " + string.Join(", ", results2) + " -> output: " + improvementcount2);
static int countimprovements(int[] results)
{
int count = 0;
for (int i = 1; i < results.Length; i++)
{
if (results[i] > results[i - 1])
{
count++;
}
}
return count;
}
string[] words = { "Hello", "World", "Programming", "communication" };
int N1 = 7;
PrintWordsOfLength(words, N1);
int N2 = 15;
PrintWordsOfLength(words, N2);
static void PrintWordsOfLength(string[] words, int N)
{
bool found = false;
foreach (string word in words)
{
if (word.Length == N)
{
Console.Write(word + " ");
found = true;
}
}
if (!found)
{
Console.WriteLine("No elements found");
}
else
{
Console.WriteLine();
}
}