Membuat Segitiga dengan Java Console

Cara membuat segitiga dengan java Console
segitiga java console
segitiga java console

import java.util.Scanner;

public class bintang
{
public static void main(String[]args)
{
int col, row, a,i ;

Scanner baca = new Scanner(System.in);

System.out.print("masukan besar segitiga: ");
a = baca.nextInt();

System.out.println();

for(row = 0 ; row < a; row++)
{
for(col = 0; col <=row; col++)
{
System.out.print("*");
}

System.out.println();
}

for(i=0; i<=a; i++)
{
for( col=a; col>i; col--)
{
System.out.print(" ");
}

for( row=1; row<=i; row++)
{
System.out.print("*");
}

System.out.println();
}

for(i=0; i<=a; i++)
{
for( col=a-i; col>0; col--)
{
System.out.print(" ");
}

for( row=1; row

Comments

Post a Comment

Popular posts from this blog

Electronic Commerce Fundamentals

Kelebihan dan Kekurangan Agile, Waterfall, Rapid Application Development(RAD), Extreme Programing(XP),Rational Unified Process (RUP), Scrum Development

MARKET RESEARCH and MARKETING PLAN REPORT Food Direktori