File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java.util.*;
2
+ import java.lang.*;
3
+ import java.io.*;
4
+
5
+ public class Main
6
+ {
7
+ public static void main (String[] args) throws java.lang.Exception
8
+ {
9
+ Scanner sc = new Scanner(System.in);
10
+ // if condition (there is no need to write else condition with if condition)
11
+ int a sc.nextInt();
12
+ int b =sc.nextInt();
13
+ if(a==b){
14
+ System.out.println(true);
15
+ }
16
+ else{
17
+ System.out.println(false);
18
+ }
19
+ //if-else if(only one condition runs which is true and no onther condition check after that)
20
+ if(a==b){
21
+ System.out.println(true);
22
+ }
23
+ else if(a!=b){
24
+ System.out.println(false);
25
+ }
26
+ else if(a>b){
27
+ System.out.println("a is greater");
28
+ }
29
+ else{
30
+ System.out.println("b is greater");
31
+ }
32
+ //if if if (all the condition runs which one is true)
33
+ if(a==b){
34
+ System.out.println(true);
35
+ }
36
+ if(a!=b){
37
+ System.out.println(false);
38
+ }
39
+ if(a>=b){
40
+ System.out.println("a is greater");
41
+ }
42
+ // switch case
43
+ int month =sc.nextInt();
44
+ switch(month){
45
+ case 1:
46
+ case 3:
47
+ case 5:
48
+ case 7:
49
+ case 8:
50
+ case 10:
51
+ case 12:
52
+ System.out.println("31");
53
+ break;
54
+ case 4:
55
+ case 6:
56
+ case 9:
57
+ case 11:
58
+ System.out.println("30");
59
+ break;
60
+ case 2:
61
+ System.out.println("28");
62
+ break;
63
+ default:
64
+ System.out.println("wrong number entered");
65
+ // we can further discuss about break statement
66
+ }
67
+ }
You can’t perform that action at this time.
0 commit comments