Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Desafio: Switch | Estruturas de Controle
Quizzes & Challenges
Quizzes
Challenges
/
Fundamentos de C#

bookDesafio: Switch

Complete the switch statement to output what day of the week it is.

main.cs

main.cs

copy
1234567891011121314151617181920212223242526272829303132
using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int day = 5; Console.Write("It is "); switch (day) { case 1: Console.WriteLine("Monday"); break; case 2: Console.WriteLine("Tuesday"); break; case 3: Console.WriteLine("Wednesday"); break; case 4: Console.WriteLine("Thursday"); break; default: Console.WriteLine("Invalid Day"); break; } } } }

Add the three missing cases for the days 5, 6 and 7.

main.cs

main.cs

copy
1234567891011121314151617181920212223242526272829303132
using System; int day = 5; Console.Write("It is "); switch(day) { case 1: Console.WriteLine("Monday"); break; case 2: Console.WriteLine("Tuesday"); break; case 3: Console.WriteLine("Wednesday"); break; case 4: Console.WriteLine("Thursday"); break; case 5: Console.WriteLine("Friday"); break; case 6: Console.WriteLine("Saturday"); break; case 7: Console.WriteLine("Sunday"); break; default: Console.WriteLine("Invalid Day"); break; }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 12

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

What should the output be for days 5, 6, and 7?

Can you show me the current switch statement code?

Do you want a brief explanation of how switch statements work in JavaScript?

bookDesafio: Switch

Deslize para mostrar o menu

Complete the switch statement to output what day of the week it is.

main.cs

main.cs

copy
1234567891011121314151617181920212223242526272829303132
using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int day = 5; Console.Write("It is "); switch (day) { case 1: Console.WriteLine("Monday"); break; case 2: Console.WriteLine("Tuesday"); break; case 3: Console.WriteLine("Wednesday"); break; case 4: Console.WriteLine("Thursday"); break; default: Console.WriteLine("Invalid Day"); break; } } } }

Add the three missing cases for the days 5, 6 and 7.

main.cs

main.cs

copy
1234567891011121314151617181920212223242526272829303132
using System; int day = 5; Console.Write("It is "); switch(day) { case 1: Console.WriteLine("Monday"); break; case 2: Console.WriteLine("Tuesday"); break; case 3: Console.WriteLine("Wednesday"); break; case 4: Console.WriteLine("Thursday"); break; case 5: Console.WriteLine("Friday"); break; case 6: Console.WriteLine("Saturday"); break; case 7: Console.WriteLine("Sunday"); break; default: Console.WriteLine("Invalid Day"); break; }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 12
some-alt