0
It gives me an error why???
public class Program { public static void main(String[] args) { int day = w; DataInputStream in = new DataInputStream (System.in); System.out.println ("Enter a Value"); w = Integer.parseInt(in.readLine []); switch(w) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wednesday");
1 Odpowiedź
+ 2
You're setting the integer variable day to an uninitialized and undeclared variable "w" on line 3. Then on line 6 you're assigning an integer to that same unknown. Try initializing your day variable to 0 and then on line 6 set the variable day to the parsed integer.
Furthermore your switch should be checking against the variable day as well.
Let me know if you need more help.