Menu

(Solved) : Please Help Package Example Public Class Methodsclass Instructions Students Use Main Meth Q43967374 . . .

Please help me.

package example;

public classMethodsClass {

   /*
   * Instructions for students: Use the main method onlyto make calls to the
   * other methods and to print some testing results. Thecorrect operation of
   * your methods should not depend in any way on thecode in main.
   *
   * Do not do any printing within the method bodies,except the main method.
   *
   * Leave your testing code in main — you will begraded on this. You can remove
   * this comment from your submission.
   */

   /**
   * In main, write code that exercises all the methodsyou write. This code
   * should call the methods with different arguments andprint out results. You
   * should think about different arguments to try thattests different cases. For
   * example, if the method returns a true or false,write code that creates a
   * true result and other code that produces a falseresult. Use print statements
   * to explain what each test is checking and the resultthat was obtained. The
   * assignment gives a small example of this. Runningthis program should output
   * a small report on examples of using the differentmethods.
   *
   * Replace this comment with your own Javadoccomment
   */
   public static void main(String[] args) {
       // Add tests here
      
   }

/**

   *Produces a String starting and ending with the edge character andhaving the
   * inner char repeated in-between. The total number ofcharacters in the string
   * is width. As an example makeLine(‘+’, ‘-‘, 8) wouldreturn the string
   * “+——+”.
   *
   * NOTE: This method is already completely implementedand must not be modified
   * for the assignment.
   *
   * @param edge The character used at the start and endof the returned string.
   * @param inner The character repeated in-between theedge char.
   * @param width The total number of characters in thereturned string. Width
   * must be greater or equal to 2.
   * @return A string with width characters.
   */
   public static String makeLine(char edge, char inner,int width) {
       String line = “”;
       int currentLocation = 0;
       // Make the middle part of the linefirst.
       while (currentLocation < width -2) {
           line = line +inner;
           currentLocation= currentLocation + 1;
       }
       // Add in the start and endcharacter to the line.
       return edge + line + edge;
   }

   /**
   * Returns a string which, when printed out, will be asquare shaped like this,
   * but of varying size (note – even though there arethe same number of
   * characters side-to-side as up-and-down, the way textis drawn makes this look
   * not like a square. We will consider it asquare.):
   *
   * <pre>
   * +—–+
   * | |
   * | |
   * | |
   * | |
   * | |
   * +—–+
   * </pre>
   *
   * The returned string should consist of width lines,each ending with a
   * newline. In addition to the newline, the first andlast lines should begin
   * and end with ‘+’ and should contain width-2 ‘-‘symbols. In addition to the
   * newline, the other lines should begin and end with’|’ and should contain
   * width-2 spaces.
   *
   * A newline is a special character use to force onestring to be on multiple
   * lines. System.out.println(“HinThere”); will produceoutput like Hi There
   *
   * The ‘n’ character is a newline.
   *
   * The method does not print anything.
   *
   * The width parameter must be greater than or equal to2.
   *
   * You should use while, if, and elsestatement.
   *
   * IMPLEMENTATION NOTE: For full credit (and for easierimplementation), make
   * use of the makeLine method provided above in yourimplementation of
   * makeRectangle. You’ll need to use a loop to callmakeLine the correct number
   * of times.
   *
   * Replace this comment with your own Javadoccomment
   */
   public static String makeSquare(int width) {
       return “”; // Replace this linewith your own code.
   }
}

Expert Answer


Answer to Please help me. package example; public class MethodsClass { /* * Instructions for students: Use the main method only to…

OR