Tampilkanlah Soal bilangan Ganjil dari 3 sampai 25
package inputtext;
/**
*
* @author Bankjeck
*/
import javax.swing.*;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int x,y;
x=1; y=23;
while (x <= y) //apakah x <= y, jika True
{
x+=2; // nilai x ditambah 2
System.out.println(+x); // cetak nilai x }
}
}
}
Hasil Output
run:
3
5
7
9
11
13
15
17
19
21
23
25
BUILD SUCCESSFUL (total time: 1 second)
package inputtext;
/**
*
* @author Bankjeck
*/
import javax.swing.*;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int x,y;
x=1; y=23;
while (x <= y) //apakah x <= y, jika True
{
x+=2; // nilai x ditambah 2
System.out.println(+x); // cetak nilai x }
}
}
}
Hasil Output
run:
3
5
7
9
11
13
15
17
19
21
23
25
BUILD SUCCESSFUL (total time: 1 second)
No comments:
Post a Comment