Question: Write a program that reads in lines from the input. Each line has a single integer followed by a single character. The objective is to

Write a program that reads in lines from the input. Each line has a single integer followed by a single character. The objective is to print a triangle pattern using the input character. The first integer represents the number of rows of the triangle. Input values will contain only integers greater than or equal to 1 and less than or equal to 50.

Input

The format of an input line is noRows char The first is an integer (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 triangular pattern is printed consisting of several rows. If the no of rows 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 *

-1 '

10 =

Sample Output

*

**

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 for this one as well.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!