Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NestedWhile
- {
- public static void main(String[]args)
- {
- Scanner input = new Scanner(System.in);
- System.out.println("Masukan angka");
- int n = input.nextInt();
- int i=1,j;
- while(i<=n)
- {
- j=1;
- if (i==1 || i==n)
- {
- while(j<=n)
- {
- System.out.print("* ");
- j++;
- }
- }
- else
- {
- while(j<=n)
- {
- if(j==1 || j==n)
- {
- System.out.print("* ");
- }
- else
- {
- System.out.print(" ");
- }
- j++;
- }
- }
- System.out.print("\n");
- i++;
- }
- }
- }
Add Comment
Please, Sign In to add comment