Question: Write a program that reads in lines from the input. Each line has two integer values followed by a single character. The objective is to
Write a program that reads in lines from the input. Each line has two integer values followed by a single character. The objective is to print a rectangle pattern using the input pattern. The first integer represents the number of rows and the second integer represents the number of columns.
Input
The format of an input line is noRows noCols char The first two are integers (and can be read using nextInt()). The last one is a single character (like *) and can be read using next() as a String and then using charAt(0) to get at the first character.
Output
For each line of input, a rectangular pattern is printed consisting of several rows. If the no of rows or cols is less than or equal to zero or more than 50, the program prints out an error statement as shown in the sample output.
Sample Input
2 2 ,
2 51 +
10 10 =
0 11 *
Sample Output
,,
,,
error in input
==========
==========
==========
==========
==========
==========
==========
==========
==========
==========
error in input
HINT 1. use in.next().charAt(0) to get the character.
2. dont forget to discard the rest of the input line using in.nextLine() if you are using in.hasNextLine() to check if there is a next line.
3. You will need TWO loops to print each rectangle.
THIS PROGRAM WILL BE PUT THROUGH A TESTING WEBSITE WHERE THEY INPUT 100+ TRIAL INPUTS AND IT MUST PASS THEM ALL WHILE RUNNING ONCE, SO IT WILL NEED TO CHECK AND COMPLETE NEXT LINE FUNCTIONS.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
