0
Can someone convert this into if-else statements?
import java.util.*; public class Tuna { public static void main(String args[]){ Scanner KB = new Scanner(System.in); String dayString1, dayString2, dayString3; int day = KB.nextInt(); switch (day){ case 1: dayString1 = "Saturday"; case 2: dayString2 = "Sunday"; break; case 3: dayString3 = "Monday"; break; case 4: dayString1 = "Tuesday"; case 5: dayString2 = "Wednesday"; break; default: dayString3 = "Invalid Day"; break; } } }
4 Respostas
0
U can simply use if else statement insted of cases
Write like this
if(day==1)
Then sat
Elseif(day==2 ) then sunday
......
...
esle Wednesday.
0
I just want to confirm if my answer is correct. Can someone post?
0
no your code posted in question description is not correct...
+ there's lack of 'thursday' and 'friday'
+ why do you use 3 different variables to hold case result?
+ don't you want to display result?
0
visph no the code is correct and no I dont wanna display any result