- 2
Can Anyone confirm the code I have written is completely correct?
5 Respuestas
+ 3
I think everything is fine, but I agree with @Lo Coding and I think that you should add the default option:
switch (age)
{
case n:
/* code*/
default:
System.out.println("Out of range");
break;
}
+ 2
Looks fine. What do you think could go wrong with this code that you had to confirm that it is correct? Just curious.
Probably you can add a default just in case the user enters a value not in range 1 to 7, something that would say 'Day limit exceeded'.
+ 2
Atharva Shinde , in addition as a default case you can add a message like for example "Invalid input" if the user's choice is not in this range 🐱
+ 2
You must add the default option:
switch (age)
{
case n:
/* code*/
default:
System.out.println("Out of range");
break;
}
Is called when the other cases are incorrect
+ 1
Thank you Guys🔥