How to Solve Problem 7. Please find my code below
package codingBlocks_Pattern;
import java.util.Scanner;
public class Ques_Seven {
private static Scanner sc;
/*
Ques 7:
n = 5
-
*
-
*
-
*
*/
public static void main(String[] args) {
sc = new Scanner(System.in);
int n = sc.nextInt();
int row = 1;
int cst = n;
int spc = 1;
while (row <= n) {
if(row == 1 || row == n) {
int st = 1;
while(st <= cst) {
System.out.print("*");
st++;
}
}else {
int st = 1;
while(st <= cst) {
System.out.print("*");
st++;
}
int sp = 1;
while( sp <= spc ) {
System.out.print(" ");
sp++;
}
}
}
cst++;
spc= spc+2;
row++;
}
}