Asterisk Rectangle – input “n” number and print “n” rows and “n-1” columns

// import scanner class

import java.util.Scanner;
// create a class

public class AsteriskRectangle {
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int i,j,n;
		System.out.println(" Enter a number : ");
		n = s.nextInt();
		
		for(i=1;i<=n;i++)
		{
			System.out.println("  ");
			
			for(j=1;j<n;j++)
			{
				System.out.print(" * ");
			}
	
		}
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *