Question: Text Boxes (JAVA beginner) Create a class named TextBoxes. At the top declare a char constant named DEFAULT_CH whose value is *. Next will be
Text Boxes (JAVA beginner)
Create a class named TextBoxes. At the top declare a char constant named DEFAULT_CH whose value is *.
Next will be main() which prompts the user to enter values for the following variables:
int sideInput
int colsInput
char c1Input
char c2Input
main() will call each of the following overloaded methods named textBoxString() and then display the results of that call. For the following, assume the user input the following values: sideInput = 3, colsInput = 4, c1Input = '+', and c2Input = 'x'.
public static String textBoxString (int side)
The returned String value, when printed, displays as a square of side characters. The character used is DEFAULT_CH. For example:
String s = textBoxString(sideInput);
System.out.println(s);
will print
***
***
***
public static String textBoxString(int side, char c1)
The returned String value, when printed, displays as a square of side characters. The character used is c1. For example:
String s = textBoxString(sideInput, c1Input);
System.out.println(s);
will print
++++ ++++ ++++ ++++
public static String textBoxString(int rows, int cols)
The returned String value, when printed, displays as a rectangle of rows rows and cols columns using DEFAULT_CH character. For example:
String s = textBoxString(sideInput, colsInput);
System.out.println(s);
will print
**** **** ****
public static String textBoxString(int rows, int cols, char c1, char c2)
The returned String value, when printed, displays a rectangle of rows rows and cols columns using alternating c1 and c2 characters. For example:
String s = textBoxString(sideInput, colsInput, c1Input, c2Input);
System.out.println(s);
will print
+x+x+ x+x+x +x+x+
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
