Koding Program NetBeans Looping
Looping Do........While
Koding Program NetBeans Looping
Looping Do........While
package agung.lestari.looping.pkg3;
public class AgungLestariLooping3 {
public static void main(String[] args) {
int a1=0;
int b1=1;
do{
System.out.println(a1);
a1=a1+b1;
} while (a1<10);
}
}
Maka akan tampil seperti gambar di bawah ini :
Tugas (a) Menampilkan Bilangan Ganjil dan Bilangan Genap
package agung.tugas.looping.pkg8;
public class AgungTugasLooping8 {
public static void main(String[] args) {
System.out.println("====================BILANGAN GENAP====================");
int a1=2;
int b1=2;
do{
System.out.println(a1);
a1=a1+b1;
} while (a1<=10);
System.out.println("====================BILANGAN GANJIL====================");
int a2=1;
int b2=1;
do{
System.out.println(a2);
a2=a2+b1;
} while (a2<=10);
}
}
Tidak ada komentar:
Posting Komentar