-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitchcondition.java
30 lines (29 loc) · 1.03 KB
/
switchcondition.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner;
public class switchcondition {
public static void main(String args[]){
Scanner a = new Scanner(System.in);
System.out.println("enter button number");
int button=a.nextInt();
/**
if(button==1){
System.out.println("numbers are equal");
}
else if (button==2){
System.out.println("numbers is greater "+b);
}
else{
System.out.println("numbers c is greater "+c);
} wrong so we use switch*/
switch(button) {
case 1 : System.out.println("numbers are equal");
break; //break is use to stop case if it is true
case 2 : System.out.println("numbers is greater ");
break;
case 3 : System.out.println("numbers are equal");
break; //break is use to stop case if it is true
case 4 : System.out.println("numbers is greater ");
break;
default : System.out.println("numbers c is greater ");
}
}
}