Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Explanation / Answer

This edior does not support tabs. So I couldn't type well here. Check http://pastebin.com/QVGuzkvb for code with proper indentation and syntax highlighting. Please rate. import java.util.*; public class prog { private static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { int length = 0; int width = 0; char chara; String quit = " "; while (!quit.equals("no")) { length = getLength(); width = getWidth(); chara = getSymbol(); if(length < 0|| width < 0) printUnfilledRectangle(length, width, chara); else printFilledRectangle(length, width, chara); quit = askIfMore(); } } public static void printMiddleLines(int length, int width, char chara, char charb) { for (int county = 0; county
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote