import javax.swing.*;
public class Main {
public static void main(String[] args) {
int x;
x=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang ?"));
for (int i=1;i<=x;i++) {
for (int j=1;j<=x;j++) {
if (j<=i)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
package classtugas_bintang2;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
int baris,x,y;
baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang ?"));
x=baris+1;
for (int i=1;i<=baris;i++) {
for (int j=1;j<=baris;j++) {
y=i+j;
if (y<=x)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
package classtugas_bintang3;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
int baris,x,y;
baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang ?"));
x=baris+1;
for (int i=1;i<=baris;i++) {
for (int j=1;j<=baris;j++) {
y=i+j;
if (x<=y)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
0 komentar:
Posting Komentar