23rd Jul 2017, 4:21 AM
Whitehat
Whitehat - avatar
4 Answers
+ 4
The code works. What are you trying to do?
23rd Jul 2017, 4:34 AM
Rrestoring faith
Rrestoring faith - avatar
+ 4
No need for a loop to improve your code and avoid the switch statement... simply do: class Paturday { public static void main(String[]args) { int day=2; String[] week = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}; System.out.println(week[day-1]); } } (indexes of arrays start at zero, so we decremente 'day' value as your switch was starting to value 1 for 'monday" ;)
23rd Jul 2017, 6:34 AM
visph
visph - avatar
0
lmao i just changed it, but can u copy the whole code but delete all the day++ and day-- and show me how a while loop would be worked into the code please thank you
23rd Jul 2017, 4:30 AM
Whitehat
Whitehat - avatar
0
add a while loop to the code
23rd Jul 2017, 5:14 AM
Whitehat
Whitehat - avatar