Untitled
unknown
plain_text
2 years ago
970 B
14
Indexable
package Exercise;
import java.util.Scanner;
public class Exercise_06_While_and_Do_While {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
//C_01_For();
TC_01_While();
//TC_01_Do_While();
}
public static void TC_01_For(){
int n = scanner.nextInt();
for (int i = n; i < 100; i++) {
if (i % 2 == 0) {
System.out.println(i);
}
}
}
public static void TC_01_While(){
int n = scanner.nextInt();
while (n<100){
if (n % 2 == 0) {
System.out.println(n);
n++;
}
}
}
public static void TC_01_Do_While(){
int n = scanner.nextInt();
do {
if (n % 2 == 0) {
System.out.println(n);
n++;
}
}
while (n<100);
}
}
Editor is loading...
Leave a Comment