My professor ask me to:
Create a code in java that will reads the length and the width of rectangle. Drawing of a rectangle with the given dimensions would be drawn using the character "#" . the program should continuously read pairs of numbers.
(first length, then width) and outputs the calculated QPI after the end of input is met.
Input:
The input file will consist of a series of pairs of integers separated by a space; one pair of integers per line. The first number in each pair is the rectangle's length while the other one is the width.
Output:
Each rectangle (with the inputted dimensions) is ouputted using the character '#'.
There should be an empty space after each drawing.
Sample Input:
1 1
2 2
3 3
Sample Output:
#
##
##
###
###
###
This is the code that I create but only 1 set of numbers is only input
import java.io.*;
public class ActivityThree {
public static void main (String[] args) {
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
String input = "";
String output = "";
int a = 0;
int b = 0;
int inputParse = 0;
int outputParse = 0;
try{
System.out.print("Enter Length: ");
input = dataIn.readLine();
System.out.print("Enter Width: ");
output = dataIn.readLine();
}catch( IOException e ){
System.out.println("Error!");
}
inputParse = Integer.parseInt(input);
outputParse = Integer.parseInt(output);
for(a = inputParse; a > 0; a--) {
for(b=0; b < outputParse; b++) {
if(a >= inputParse)
System.out.print("#");
else
System.out.print("#");
}
System.out.print("\n");
}
}
}