Rectangle V2 Learn programming Java

Lesson:

Flow Control


Exercise:

Rectangle V2 40


Objetive:

Write a java program which asks for a number, a width and a height and displays a rectangle of that width and that height, using that number for the inner symbol, as in this example:

Enter a number: 4
Enter the desired width: 3
Enter the desired height: 5

444
444
444
444
444


Code:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		int n;
		int row, column;

		System.out.print("Enter a number: ");
		n = Integer.parseInt(new Scanner(System.in).nextLine());

		System.out.print("Enter the desired: ");
		width = Integer.parseInt(new Scanner(System.in).nextLine());

		System.out.print("Enter the desired height: ");
		height = Integer.parseInt(new Scanner(System.in).nextLine());

		for (row = 0; row; row++)
		{
			for (column = 0; column; column++)
			{
				System.out.print(n);
			}

			System.out.println();
		}
	}
}