Skip to content

Commit 87b3483

Browse files
conditional statements && while loop,do while loop
1 parent 19e5ae9 commit 87b3483

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
2.04 KB
Binary file not shown.
152 Bytes
Binary file not shown.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package clasi;
2+
3+
public class Caluculator {
4+
5+
public static void main(String[] args) {
6+
// Math operator
7+
int x, y, ans;
8+
x = 1;
9+
y = 2;
10+
ans = x * y;
11+
int aans = x + y;
12+
double ans1 = x % y;
13+
float ans2 = x / y;
14+
15+
System.out.println("Answer is = " + ans);
16+
System.out.println("Answer is = " + aans);
17+
System.out.println("Answer is = " + ans1);
18+
System.out.println("Answer is = " + ans2);
19+
20+
// incrementation
21+
22+
int x1 = 10;
23+
x1 *= 5;
24+
25+
// x++;
26+
System.out.println(x1++);
27+
System.out.println(x1);
28+
29+
System.out.println(x1);
30+
31+
32+
33+
// conditional statements
34+
int s = 10;
35+
36+
if (s == 100) {
37+
System.out.println("yes s = 10");
38+
} else {
39+
System.out.println("no s != 10");
40+
}
41+
42+
// logical opertaor
43+
44+
int sub1 = 99;
45+
int sub2 = 100;
46+
// (and == &&) , (or == ||)
47+
if ((sub1 >= 35 ) && (sub2 >= 35)) {
48+
System.out.println("The condition is true");
49+
System.out.println("the is passed");
50+
} else {
51+
System.out.println("The condition is false");
52+
}
53+
54+
// switch statements
55+
int score1 = 190;
56+
57+
switch (score1) {
58+
case 90:
59+
System.out.println("very good");
60+
break;
61+
case 60:
62+
System.out.println("good");
63+
break;
64+
case 40:
65+
System.out.println("average");
66+
break;
67+
case 20:
68+
System.out.println("need to improve");
69+
break;
70+
default:
71+
System.out.println("The grades are not define");
72+
break;
73+
74+
}
75+
76+
int w = 10;
77+
78+
while (w < 10) {
79+
80+
w++;
81+
System.out.println(w);
82+
w--;
83+
System.out.println(w);
84+
break;
85+
86+
}
87+
88+
int d = 10;
89+
90+
do {
91+
System.out.println(d);
92+
d++;
93+
System.out.println(d);
94+
break;
95+
}while (d == 10);
96+
97+
98+
}
99+
100+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
*
3+
*/
4+
/**
5+
*
6+
*/
7+
module MathOperators {
8+
}

0 commit comments

Comments
 (0)