Jumat, 15 November 2013

Program Perulangan 2 pada JAVA

 import java.util.*;
public class segitiga2 {

    public static void main(String[] args) {
  
        Scanner input = new Scanner(System.in);
        int a,b,c,d,e;
  
        System.out.print("Masukan Angka : ");
        a = input.nextInt();
  
        e=a-1;
        for(b=1;b<=a;b++)
        {
             for(d=e;d>=1;d--)
             {
                 System.out.print("  ");
             }
             for(c=1;c<=b;c++)
             {
                 System.out.print("* ");
             }
             e=e-1;
             System.out.println("");
        }   
  
        System.out.println("\n\n");              
    }
      
}

0 komentar:

Posting Komentar

Please Leave Your Comment :)