Day-35: While Loop practice in java
public class EvenNumbers { public static void main(String[] args) { int i = 2; while (i = 2) { System.out.println(i); i -= 2; } } } Output: 10,8,6,4,2 Example3: package While; public class RverseMultipleThree { public static void main(String[] args) { int i = 15; while (i >= 3) { System.out.println(i); i -= 3; } } } Output: 15,12,9,6,3 Example4: package While; public class MutipleThree { public static void main(String[] args) { int i = 3; while (i 24) { System.out.print(","); } } a -= 2; } } } Output: 36,34,30,28,24

public class EvenNumbers {
public static void main(String[] args) {
int i = 2;
while (i <= 10) {
System.out.println(i);
i += 2;
}
}
}
Output:
2,4,6,8,10
EXAMPLE2:
public class ReverseEvenNumbers {
public static void main(String[] args) {
int i = 10;
while (i >= 2) {
System.out.println(i);
i -= 2;
}
}
}
Output:
10,8,6,4,2
Example3:
package While;
public class RverseMultipleThree {
public static void main(String[] args) {
int i = 15;
while (i >= 3) {
System.out.println(i);
i -= 3;
}
}
}
Output:
15,12,9,6,3
Example4:
package While;
public class MutipleThree {
public static void main(String[] args) {
int i = 3;
while (i <= 15) {
System.out.println(i);
i += 3;
}
}
}
Output:
3,6,9,12,15
Example5:
package While;
public class Number {
public static void main(String[] args) {
int a = 7;
int b = 10;
while (a <= 10 && b <= 13) {
System.out.print(a + "," + b);
if (a < 10 && b < 13) {
System.out.print(",");
}
a = a + 1;
b = b + 1;
}
}
}
Output:
7,10,8,11,9,12,10,13
Example6:
package While;
public class Number2 {
public static void main(String[] args) {
int a = 10;
while (a <= 50) {
System.out.print(a);
if (a < 50) {
System.out.print(",");
}
a += 10;
}
}
}
Output:
10,20,30,40,50
Example7:
package While;
public class Number3 {
public static void main(String[] args) {
int a = 90;
while (a >= 15) {
System.out.print(a);
if (a > 15) {
System.out.print(",");
}
a -= 15;
}
}
}
Output:
90,75,60,45,30,15
Example8:
package While;
public class Number4 {
public static void main(String[] args) {
int a = 36;
while (a >= 24) {
if (a != 32 && a != 26) { // Skip 32 and 26
System.out.print(a);
if (a > 24) {
System.out.print(",");
}
}
a -= 2;
}
}
}
Output:
36,34,30,28,24