Answer to Question #233614 in Java | JSP | JSF for Simon

Question #233614

How to write a java program that asks user for a number and Prints out a series of squares of stars in increasing size up the number provided by the user.


1
Expert's answer
2021-09-06T00:16:22-0400


import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
	    Scanner in=new Scanner(System.in);
	    System.out.println("Enter the number of rows: ");
	    int num=in.nextInt();	 
        for(int i = 1; i <= num; i++)
		{
			for(int j = 1; j <= num; j++)
			{
				System.out.print("*"); 
			}
			System.out.print("\n"); 
		}	     
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS