This repository was archived by the owner on Jun 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidk
More file actions
273 lines (165 loc) · 5.12 KB
/
Copy pathidk
File metadata and controls
273 lines (165 loc) · 5.12 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("A proud knight named...");
Console.ReadLine();
Console.WriteLine("...walked into a bar. At the counter he met a...");
Console.ReadLine();
Console.WriteLine("...who asked him what he wanted to drink?");
Console.ReadLine();
Console.WriteLine("...shouted the knight! The bartender shushed him quickly.");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("But it was too late... A dragon ate them both.");
// Wait before closing
Console.ReadKey();
}
}
}
--------------------------------
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
// Declare variables
double num01;
double num02;
double num03;
// Get first number
Console.Write("Input a number: ");
num01 = Convert.ToDouble(Console.ReadLine());
// Get second number
Console.Write("Input a second number: ");
num02 = Convert.ToDouble(Console.ReadLine());
// Get third number
Console.Write("Input a third number: ");
num03 = Convert.ToDouble(Console.ReadLine());
// Calculate and display the average
double result = (num01 + num02 + num03) / 3;
Console.WriteLine("The average of these numbers is " + result);
// Wait before closing
Console.ReadKey();
}
}
}
-----------------//--------------------
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
int answer;
// First problem
Console.Write("15 + 2 * 2 = ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 60) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}
// Second problem
Console.Write("10 * 2 / 4 = ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 5) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}
// Third problem
Console.Write("(4 + 3 + 2 + 1) / 2 = ");
answer = Convert.ToInt32(Console.ReadLine());
if (answer == 6) {
Console.WriteLine("Correct!");
} else {
Console.WriteLine("Wrong!");
}
// Wait before closing
Console.ReadKey();
}
}
}
-------------------------------------------------
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Random numberGen = new Random();
int roll01 = 0;
int roll02 = 1;
int attempts = 0;
Console.WriteLine("Press enter to roll the dice.");
while(roll01 != roll02)
{
Console.ReadKey();
roll01 = numberGen.Next(1, 7);
roll02 = numberGen.Next(1, 7);
Console.WriteLine("Roll 1: " + roll01);
Console.WriteLine("Roll 2: " + roll02 + "\n");
attempts++;
}
Console.WriteLine("It took you " + attempts + " attempts to roll two of a kind.");
// Wait before closing
Console.ReadKey();
}
}
}
--------------------------------
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Console.Write("How many students are in your class: ");
int studentCount = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please input the names of the students: ");
string[] students = new string[studentCount];
for (int i = 0; i < studentCount; i++)
{
students[i] = Console.ReadLine();
}
Console.WriteLine("--------------");
Array.Sort(students);
for (int i = 0; i < studentCount; i++)
{
Console.WriteLine(students[i]);
}
// Wait before closing
Console.ReadKey();
}
}
}
---------------------------------------
using System;
namespace My_Awesome_Program
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a sentence: ");
string sentence = Console.ReadLine();
int wordCount = CountWords(sentence);
Console.WriteLine("There are " + wordCount + " words in that sentence.");
// Wait before closing
Console.ReadKey();
}
static int CountWords (string sentence) {
int wordCount = sentence.Split(' ').Length;
return wordCount;
}
}
}
-----------________________