import java.util.Scanner; public class SquarePattern { public static void main(String[] args) { String pattern; int noOfTimes; Scanner scanner = new Scanner(System.in); System.out.print("Enter the...

import java.util.Scanner;
public class SquarePattern {

public static void main(String[] args) {

String pattern; int noOfTimes;

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the pattern to print : "); pattern = scanner.nextLine();

System.out.print("Enter number of times it should get printed : "); noOfTimes = scanner.nextInt();

for(int i=1; i System.out.println();

if(i==1 || i==noOfTimes) { for(int j=1; j System.out.print(pattern+" "); } } else { for(int k=1; k if(k==1 || k == noOfTimes) { System.out.print(pattern + " "); } else { System.out.print(" "); } } } } }}
Sep 01, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here