forked from amanss00/ForNewbies
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhileLoop.java
More file actions
50 lines (45 loc) · 1.11 KB
/
WhileLoop.java
File metadata and controls
50 lines (45 loc) · 1.11 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class main {
public static void main(String[] args) {
// int count = 1;
// while (count != 6){
// System.out.println("Count is " + count);
// count++;
// }
//
// count = 1;
// while (true){
// if (count == 6){
// break;
// }
// System.out.println("Count is " + count);
// count++;
// }
//
// count=1;
// do {
// System.out.println("Count is " + count);
// count++;
// }while (count!=6);
int count = 0;
int num = 4;
int finishNum = 20;
while (num <= finishNum){
num++;
if (!isEvenNumber(num)){
continue;
}
System.out.println("Even Number is " + num);
count++;
if (count == 5){
break;
}
}
System.out.println("Total even number found " + count);
}
public static boolean isEvenNumber(int num){
if ((num % 2) == 0){
return true;
}
return false;
}
}