it konsultan

Selasa, 07 Desember 2010

mebuat segitiga dengan java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jeri;
import javax.swing.*;
/**
 *
 * @author xp
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int a,b,c,d,x ;
        String Sx=JOptionPane.showInputDialog("Masukan Tingginya");
        x=Integer.parseInt(Sx);
        for (a=1;a<=x;a++)
        {
            for (b=1;b<=100-a;b++)
            {
                System.out.print(" ");
            }
                for (c=1;c<=a-1;c++)
            {
                System.out.print("*");
            }
                for (d=1;d<=a-1;d++)
            {
                System.out.print("*");
            }
                System.out.println("*");
          
        }
           }

}

BoxChat

UPDATE BOLA