Skip to content

Commit c44eb2a

Browse files
Naveen KhuntetaNaveen Khunteta
authored andcommitted
IF eLse and conditional
1 parent 8084b0b commit c44eb2a

10 files changed

Lines changed: 120 additions & 1 deletion
1.19 KB
Binary file not shown.

bin/JavaSessions/DataTypes.class

60 Bytes
Binary file not shown.
834 Bytes
Binary file not shown.
717 Bytes
Binary file not shown.
65 Bytes
Binary file not shown.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package JavaSessions;
2+
3+
public class ConditionalOperators {
4+
5+
public static void main(String[] args) {
6+
7+
int a = 200;
8+
int b = 300;
9+
10+
//= vs ==
11+
if(a==b){
12+
System.out.println("a and b are equal");
13+
}
14+
else{
15+
System.out.println("a and b are not equal");
16+
}
17+
18+
if(b>a){
19+
System.out.println("b is greater than a");
20+
}else{
21+
System.out.println("a is greater than b");
22+
}
23+
24+
if(b>=a){
25+
System.out.println("b is greater than equal to a");
26+
}
27+
28+
//< > <= >= <> !=
29+
int c = 10;
30+
int d = 20;
31+
if(c!=d){
32+
System.out.println("c is not equal to d");
33+
}
34+
35+
//WAP to print the highest number (given three variables)
36+
int x = 500;
37+
int y = 400;
38+
int z = 600;
39+
40+
if(x>y && x>z){ //true && false
41+
System.out.println("x is the highest number");
42+
}
43+
else if(y>z){//false
44+
System.out.println("y is the highest number");
45+
}
46+
else{
47+
System.out.println("z is the highest number");
48+
}
49+
50+
51+
52+
53+
54+
}
55+
56+
}

src/JavaSessions/DataTypes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void main(String[] args) {
2222
System.out.println(age);
2323
System.out.println(i+j);
2424

25-
//2. double (8bytes), float(4 bytes)
25+
//2. double (8 bytes), float(4 bytes)
2626
double d1 = 12.33;
2727
double d2 = -12.33;
2828
double d3 = 100; //100.00
@@ -51,6 +51,8 @@ public static void main(String[] args) {
5151
System.out.println("Hello Testing");
5252
System.out.println(s1+s2);
5353

54+
float v = (float) 12.33;
55+
System.out.println(v);
5456

5557
}
5658

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package JavaSessions;
2+
3+
public class IncrementalAndDecremental {
4+
5+
public static void main(String[] args) {
6+
7+
int i = 1;
8+
int j = i++; //post increment
9+
10+
System.out.println(i);//2
11+
System.out.println(j);//1
12+
13+
int m = 1;
14+
int n = ++m; //pre increment
15+
16+
System.out.println(m);//2 2 2 2 2 2 2
17+
System.out.println(n);//2 2 2 2 2 2 2
18+
19+
int p = 2;
20+
int q = p--; //post decrement
21+
System.out.println(p); //1 1 1 1 1 1 1
22+
System.out.println(q); //0 2 2 2 2 2 2
23+
24+
int c = 2;
25+
int d = --c; //pre decrement
26+
System.out.println(c); //1
27+
System.out.println(d); //1
28+
}
29+
30+
}

src/JavaSessions/LoopsConcept.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package JavaSessions;
2+
3+
public class LoopsConcept {
4+
5+
public static void main(String[] args) {
6+
7+
//1. while loop:
8+
//print 1 to 10:
9+
int i = 1; //Initialization
10+
while(i<=10){ //Conditional
11+
System.out.println(i);
12+
i++; //Incremental
13+
}
14+
15+
System.out.println("******");
16+
17+
//2. for loop:
18+
for(int j=1; j<=10; j++){
19+
System.out.println(j);
20+
}
21+
22+
//print 10 to 1
23+
24+
25+
}
26+
27+
}

src/JavaSessions/StringConcatenation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public static void main(String[] args) {
3535
long id = 12345;
3636
System.out.println("your transaction id is "+ id);
3737

38+
char c1 = 'a'; //ASCII Code 97
39+
char c2 = 'b'; //98
40+
//a-z A-Z 0-9
3841

42+
System.out.println(c1+c2);
3943

4044

4145
}

0 commit comments

Comments
 (0)