Selamat malam sobat berbagi ilmu. Setelah tadi kita membahas tentang Segitiga Bintang sekarang kita akan mencoba membuat Persegi. oke langsung saja kita coba :
berikut Source Code :
import java.util.Scanner;
public class for4{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for(int i=0;i<n;i++){
System.out.print("*");
}
System.out.println();
for(int i=0;i<n-2;i++){
System.out.print("*");
for(int j=0;j<n-2;j++){
System.out.print(" ");
}
System.out.println("*");
}
for (int i=0;i<n;i++){
System.out.print("*");
}
System.out.println();
}
}
Dan hasilnya seperti ini :
Semoga bermanfaat :)
Home »
» segitiga
segitiga
Penulis : Unknown on Thursday, January 17, 2013 | 7:04 AM
Related posts:
If you enjoyed this article just click here, or subscribe to receive more great content just like it.
Subscribe to:
Post Comments (Atom)
Post a Comment