Page 47 - PowerPoint Presentation
P. 47
1.4 1.4.3 MENERANGKAN ALIRAN STRUKTUR
KAWALAN ULANGAN
CONTOH ATURCARA OUTPUT
public class contoh36 { 12345678910.
public static void main (String [] args) {
int i ;
for ( i = 1 ; i <=100 ; i+=1) {
System.out.print (“i” ) ;
}
}
}
public class contoh37 { 5049
public static void main (String [] args) {
int jumlah = 0 ;
for ( i = 2 ; i <=100 ; i+=1) {
jumlah = jumlah + i ;
}
System.out.println (“Jumlah : ” + jumlah ) ;
}
}
public class contoh38 { 1,3,5,7,9,11,15,17,19,23,25,27,29
public static void main (String [] args) {
for ( i = 0 ; i <= 30 ; i+=1) {
if ((i % 2) == 2)
System.out.print ( i + “, ” ) ;
}
}
}
public class contoh39 { Baki 5 tahun : 805.255
public static void main (String [] args) {
double baki = 500.0;
for ( i = 0 ; i <= 5 ; i+=1) {
baki = baki + (0.1 * baki);
}
System.out.printn ( “ Baki 5 tahun : “ + baki) ;
}
47
}

