+ 3

Find fault.

help me to find fault in this program import java.util.Scanner; public class Main { public static void main(String[]args) { Scanner n=new Scanner(System.in); System.out.println(n); int x=n.nextInt(); switch(x) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tue"); } } }

26th May 2018, 6:41 AM
Hisham Tariq Butt
Hisham Tariq Butt - avatar
4 Respuestas
+ 3
You can't print n because it is a Scanner.
26th May 2018, 8:55 AM
Ibaadi Jaya
Ibaadi Jaya - avatar
+ 1
you need break; after case 2
26th May 2018, 7:05 AM
Struggle
Struggle - avatar
+ 1
You can also add deafult case (if user input will not be 1 or 2)
26th May 2018, 7:07 AM
Struggle
Struggle - avatar