Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #####
- # #
- # #
- # #
- # #
- #####
- */
- import java.util.Scanner;
- public class segiempat
- {
- public static void main (String[]args)
- {
- Scanner scan = new Scanner (System.in);
- int n;
- System.out.print("Masukkan Angka Batas : ");
- n= scan.nextInt();
- if (n > 2)
- {
- for (int i=0; i < n; i++)
- {
- for (int j=0; j < n; j++)
- {
- if ((i==0) || (i==n-1) || (j==0) || (j==n-1))
- {
- System.out.print("*");
- }
- else
- {
- if (n%2==1)
- {
- {
- System.out.print(" ");
- }
- }
- else
- {
- System.out.print(" ");
- }
- }
- }
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement