forked from OpenGuide/Java-Guide-for-Beginners
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSelection_Statements.java
More file actions
36 lines (30 loc) · 979 Bytes
/
Selection_Statements.java
File metadata and controls
36 lines (30 loc) · 979 Bytes
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
31
32
33
34
35
36
package selectionstatements;
public class Selection_Statements {
public static String IfElse(int x){
if(x%2==0){
return "even";
}
else{
return "odd";
}
}
public static String Switch(int x){
switch(x){
case 1 :
return "it's one";
case 2 :
return "it's two";
case 3 :
return "it's three";
default:
return "out of my knowledge";
}
}
public static void main(String[] args) {
Selection_Statements obj = new Selection_Statements();
String y = obj.IfElse(123);
System.out.println("The number is "+ y);
String x=obj.Switch(2);
System.out.println("switch statements result is :"+ x);
}
}