Question 11 of the PDF (Pyramid)

//here is my code, How do i correct it ?

import java.util.Scanner;

public class pattern11 {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	int st = 1;
	int sp = 4;
	
	
	for(int i=0; i<n; i++) {
		
		for(int j=1; j<=sp ; j++) {
			System.out.print(" ");			
		}
		for(int j=1;j<=st;j++) {
			System.out.print("*");
		}
		st+=2;
		System.out.println();
		
	}

}

}

@piyushpunia2013_edbb5b6cbb8c0354 look for comments in the code provided to see the changes that I have made.

I think this isn’t the correct pattern if you check ,the base of the pyramid has only five stars in them and this pattern has 9, please check the pattern for question eleven, thankyou

@piyushpunia2013_edbb5b6cbb8c0354 This depends on the value of n you give in input. If you have given 9 then you will get 9 stars. if you have given 4 you will get 4 stars.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.