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.
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");
}
}
}
Comments
Leave a comment