+ 1

What is the problem of my code ?

int num= Convert.ToInt32(Console.ReadLine()); switch(num){ case 1: Console.WriteLine("Easy"); break; case 2: Console.WriteLine("Medium"); break; case 3: Console.WriteLine("Hard"); break; default: Console.WriteLine("invalid"); break; }

18th Jul 2022, 3:24 PM
yasitha ranasinghe
yasitha ranasinghe - avatar
7 Answers
+ 1
What wrong you are getting? Pls add clear details..
18th Jul 2022, 3:26 PM
Jayakrishna 🇮🇳
+ 1
Yeah after this i changed that as a "invalid option but its wrong int num= Convert.ToInt32(Console.ReadLine()); switch(num){ case 1: Console.WriteLine("Easy"); break; case 2: Console.WriteLine("Medium"); break; case 3: Console.WriteLine("Hard"); break; default: Console.WriteLine("invalid option"); break; } in order to my code case 1 and 2 ,4correct but 5and 3 wrong c
18th Jul 2022, 3:31 PM
yasitha ranasinghe
yasitha ranasinghe - avatar
+ 1
Ohh ok i got it i will try ,thank u very for your help🙏🙏 thnk u sir
18th Jul 2022, 3:36 PM
yasitha ranasinghe
yasitha ranasinghe - avatar
0
You are making a game, where the player selects the difficulty level: 1 - Easy 2 - Medium 3 - Hard You are given a program that takes the number as input. Complete the program so that it will output the corresponding difficulty level. If the user entered an invalid number, the program should output "Invalid option". Sample Input 2 Sample Output Medium this is the problem 👆
18th Jul 2022, 3:27 PM
yasitha ranasinghe
yasitha ranasinghe - avatar
0
In this case they told my code is wrong why? i cant understand my fault
18th Jul 2022, 3:28 PM
yasitha ranasinghe
yasitha ranasinghe - avatar
0
Oh. Asked to put "Invalid option" in default.. But you are printing "invalid" edit: yasitha ranasinghe capital I in "Invalid option"..
18th Jul 2022, 3:30 PM
Jayakrishna 🇮🇳
0
You're welcome.....
18th Jul 2022, 3:37 PM
Jayakrishna 🇮🇳