Advertisement
MarioDimitrov

Untitled

Nov 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task17 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.         int b;
  8.         char c;
  9.         do{
  10.             System.out.print("(length) b = ");
  11.             b = scan.nextInt();
  12.             System.out.print("(inner symbol) c = ");
  13.             c = scan.next().charAt(0);
  14.         }while(b<3 || b>20);
  15.        
  16.         for(int row=1; row<=b; row++){
  17.            
  18.             if(row==1 || row==b){
  19.                 //first and last rows
  20.                 for(int i=0; i<b;i++){
  21.                     System.out.print("* ");
  22.                 }
  23.                 System.out.println();
  24.             }else{
  25.                 for(int col=1; col<=b; col++){
  26.                    
  27.                     if(col==1 || col==b){
  28.                         //first and last columns
  29.                         System.out.print("* ");
  30.                     }else
  31.                         System.out.print(c+" ");
  32.                 }
  33.                 System.out.println();
  34.             }
  35.         }
  36.  
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement