Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Task17 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int b;
- char c;
- do{
- System.out.print("(length) b = ");
- b = scan.nextInt();
- System.out.print("(inner symbol) c = ");
- c = scan.next().charAt(0);
- }while(b<3 || b>20);
- for(int row=1; row<=b; row++){
- if(row==1 || row==b){
- //first and last rows
- for(int i=0; i<b;i++){
- System.out.print("* ");
- }
- System.out.println();
- }else{
- for(int col=1; col<=b; col++){
- if(col==1 || col==b){
- //first and last columns
- System.out.print("* ");
- }else
- System.out.print(c+" ");
- }
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement