Your program will:
Here is a sample dialog from running the program 4 times, first for just the line of stars:
Please enter a number: 3 *** Please enter a number: 16 **************** Please enter a number: -3 *** That is not a valid entry. *** Please enter a number: 2 **
Note: the example dialogs (above and below) show running the program 4 different times.
The code to print the line of stars should be in a method called printStars(); here is the signature to use:
public static void printStars(int numStars)
After a printing a single line of stars is working, then add the triangle part:
Write another method called printTriangle()
that takes a single integer argument and
uses your printStars() function to print the side-ways
triangle, with the point the number of stars the user types in. This should also be static.
Then change your main() to use your printTriangle() function to print the triangle.
Here is a sample dialog from running the completed program 4 times:
Please enter a number: 3 * ** *** ** * Please enter a number: 16 * ** *** **** ***** ****** ******* ******** ********* ********** *********** ************ ************* ************** *************** **************** *************** ************** ************* ************ *********** ********** ********* ******** ******* ****** ***** **** *** ** * Please enter a number: -3 *** That is not a valid entry. *** Please enter a number: 2 * ** *Optional: Write the program such that the string used to draw the triangle is passed in as an argument, hardcoded in main. you should still have a printStars() method, with the same signature specified above. How does this change your design from that which is given? Can you then update your program to take the string as a command-line argument? And use a star ("*") if no argument is specified?