+ 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; }
7 Answers
+ 1
What wrong you are getting?
Pls add clear details..
+ 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
+ 1
Ohh ok i got it i will try ,thank u very for your help🙏🙏
thnk u sir
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 👆
0
In this case they told my code is wrong
why? i cant understand my fault
0
Oh. Asked to put "Invalid option" in default..
But you are printing "invalid"
edit:
yasitha ranasinghe capital I in "Invalid option"..
0
You're welcome.....