Selasa, 29 Maret 2011

Program Loop pada java

import javax.swing.*;
class loop{
public static void main(String [] args){
int angka=Integer.parseInt(JOptionPane.showInputDialog("Input Angka : "));
for (int i=1; i<=angka; i++){ for (int j=1; j<=i; j++){ System.out.print("#");} System.out.print("\n");} for (int i=angka; i>=0; i--){
for (int j=i; j>1; j--){
System.out.print("#");}
System.out.print("\n");}
}}

Output
*
**
***
**
*

Tidak ada komentar:

Posting Komentar