/**
* Title : Program demo while
* Deskripsi: Mendemonstrassikan pemakaian perulangan while untuk mencetak statement ke console sebanyak n kali
*/
public class DemoWhile {
/** Main Method */
public static void main(String[] args){
int counter = 0; // Inisialisasi counter
System.out.println("\nPROGRAM DEMO WHILE");
System.out.println("-------------------\n");
while ( counter <= 5 ){ // Kondisi perulangan
System.out.println( "Mencetak counter ke-" + counter );
++counter; // Menaikkan counter dengan 1
}
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment