Selasa, 17 September 2019

Struktur kontrol perulangan

Nama : Novia Dwi Jayanti
Kelas: XI Rpl 1
Mata pelajaran: Pemrograman berorientasi objek



•Struktur kontrol perulangan
While
public class While {

    public static void main(String[] args) {
        int a = 8;
        while (a>6)
        {
            System.out.print(a);
            a--;
        }
    }
}
Do While

        public class DoWhile {

    public static void main(String[] args) {
        do
        {
            System.out.println("Hello. Nice to meet you!!");
        }
        while(true);
   }
}
For
public class For {
    public static void main(String[] args) {
        int i;
        for(i=5; i<15; i++);
        {
            System.out.print(i);
        }
    }
 
}

Tidak ada komentar:

Posting Komentar