Tuesday, November 27, 2012

LOOPING WITH JAVA

package belajarlooping;

/**
 *
 * @author Hartoni
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int himpunan;
        for(himpunan=1; himpunan<=10; himpunan ++){
            System.out.print(" a" +himpunan+" ");
        }
        himpunan = 2;
        while(himpunan <=5){
            System.out.print(" b"+himpunan+" ");
            himpunan++;
        }
        himpunan = 3;
        do {
            System.out.print(" c"+himpunan+" ");
            himpunan++;       
        }while(himpunan <=8);
    }
}

Output
a1  a2  a3  a4  a5  a6  a7  a8  a9  a10  b2  b3  b4  b5  c3  c4  c5  c6  c7  c8

No comments:

Post a Comment

Silahkan Berkomentar Disini :