hello...would anyone be able to help me figure out this complicated assignment...i am pretty new to java...and i am studying for a midterm...this was one of the assignments we were to review...but i have no idea how to work around it...
Java program with three static methods (in addition to the main method): getValidInt, drawParallelogram, and drawTriangle. The main method will repeatedly prompt the user with a choice of: draw a parallelogram, draw a triangle, or quit. If the user asks for a parallelogram, use getValidInt to prompt for height (between 1 and 40) and for width (between 1 and 60), and call drawParallelogram, if a triangle, prompt for height (between 1 and 30), and call drawTriangle with a random choice of character from 'A' to 'Z'. If the user wants to quit, the program should terminate. Handle invalid input gracefully (i.e., don't just allow the program to crash). Please name your class a3q1.
Now some details:
Input/output in main:
The program will use JOptionPane for input (the user will enter 'p' or 'P' for a parallelogram, 't' or 'T' for a triangle, and 'q' or 'Q' to quit). If the user enters anything else,
you should print "Invalid input" to System.out and prompt the user for a choice again. Output from the called methods will go to System.out, and main should print a final message identifiying the programmer and stating that the program ends normally.
getValidInt:
Input parameters include an int lowerBound, an int upperBound, and a
String description containing a description of the value to enter. getValidInt will prompt the user for an integer quantity between the lower and upper bounds, using JOptionPane. The message to the user will use the description, and will state the bounds. Check the user's response against the bounds. Give the user three chances to enter a valid result. If this method receives a valid input, it will return it to the calling program. Otherwise it will return a value 1 less than the lower bound. The method should look like
public static int getValidInt(int iLowerBound, int iUpperBound, String strDescription) {
...
}
drawParallelogram:
Input parameters include ints height and width. This method will display a parallelogram made of stars of the specified size. Use System.out.print and System.out.println to draw the parallelogram.
Example: if height is 4 and width is 20, the parallelogram should look like this:
********************
********************
********************
********************
The method should look like:
public static void drawParallelogram(int iHeight, int iWidth) {
...
}
drawTriangle:
Input parameters include the height int iHeight and the fill character char chFillCharacter. This method displays a triangle made of the filler char. Use System.out.print and System.out.println to output the triangle.
Example: if height is 5 and filler is 'A', the triangle will look like this:
AAAAA
AAAA
AAA
AA
A
The method should look like:
public static void drawTriangle(int iHeight, char chFillCharacter) {
...
}
Random Letter Generation:
To generate a random character between 'A' to 'Z', use the Math.random() routine. This routine gives a number between 0.0 and (<
1.0. Here is what you do to get a random letter between 'A' and 'Z':
Declare a variable ch of type char.
Compute (int)(Math.random()*26) and store in a variable, say iTemp of type int.
Set ch = (char)('A' + iTemp). ch will now contain a random character between 'A' and 'Z'.
THANK YOU in advance...