Week 1: Lection 3

1 min read
Hello, and welcome, my fellow coders! Today, I learnt about conditions and if statements. As you know, I’m familiar with Coding 101, so I found this very straightforward. The only mistake I made was forgetting to check that semicolons shouldn't be used after if statements. I successfully completed two tasks set by ChatGPT to help me consolidate what I have learnt, as well as a mini quiz.
Console.WriteLine("Napiš své jméno:");
string jmeno = Console.ReadLine();
Console.WriteLine("Napiš svůj věk:");
int vek = int.Parse(Console.ReadLine());
if (vek == 15 && jmeno == "Oliver")
{
Console.WriteLine("Ahoj, Olivere! Ty jsi ten správný člověk na C#!");
}
else
{
Console.WriteLine("Ahoj, ale nejsi ten, koho hledám.");
}
Console.WriteLine("Zvol sport dle čísla: (1 = fotbal, 2 = hokej, 3 = formule)");
int sport = int.Parse(Console.ReadLine());
switch (sport)
{
case 1:
Console.WriteLine("Zvolil sis fotbal!");
break;
case 2:
Console.WriteLine("Zvolil sis hokej!");
break;
case 3:
Console.WriteLine("Zvolil sis formule!");
break;
default:
Console.WriteLine("Neznám ten sport.");
break;
}
0
Subscribe to my newsletter
Read articles from Oliver Seidl directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
