You are to complete the rewrite of your Lab 5B program so that it contains addit
ID: 3631325 • Letter: Y
Question
You are to complete the rewrite of your Lab 5B program so that it contains additional methods which get the character to be used as well as methods that output the filled and unfilled rectangle. A suggested list of methods is: pgmDescription(); getLength(), getWidth(), getSymbo()l, printFilledRectangle(), printUnFilledRectangle(), askIfMore(), etc.Code from my original
import java.util.*;
public class main
{public static void main(String[] args)
{Scanner keyboard = new Scanner(System.in);
int length = 0;
int width = 0;
char chara;
char charb;
String quit = " ";
while (!quit.equals("no")) {
System.out.print("Enter the length of the rectangle (-10 to +10): ");
length = keyboard.nextInt();
while (Math.abs(length) < -10 || Math.abs(length) > 10||length==0) {
System.out.println("Input Error -----");
System.out.print("Enter the length of the rectangle (-10 to +10): ");
length = keyboard.nextInt();
}
System.out.print("Enter the non zero length of the rectangle (-10 to +10): ");
width = keyboard.nextInt();
while (Math.abs(width) < -10 || Math.abs(width) > 10||width==0) {
System.out.println("Input Error -----");
System.out.print("Enter the non zero length of the rectangle (-10 to +10): ");
width = keyboard.nextInt();
}
System.out.print("Enter the symbol to be used: ");
chara =keyboard.next().charAt(0);
if(length<0||width<0)
charb=' ';
else
charb=chara;
for (int countx = 0; countx < Math.abs(length); countx++) {//top line
System.out.print(chara);
}
System.out.println();
for (int county = 0; county < Math.abs(width)-2; county++) { // middle lines
System.out.print(chara);
for (int countx = 0; countx < Math.abs(length)-2; countx++) {
System.out.print(charb);
}
System.out.print(chara);
System.out.println();
}
for (int countx = 0; countx < Math.abs(length); countx++) {//bottom line
System.out.print(chara);
}
System.out.println();
System.out.println("Do you want another rectangle, Yes or No: ");
quit = keyboard.next();
quit = quit.toLowerCase();
}
}
}
Code is written in java.
I appreciate all of the help