Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me. package a1; public class Methods { /* * Instructions for students: Use the main method only to make calls to the *

Please help me.

package a1;

public class Methods {

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

/** * In main, write code that exercises all the methods you write. This code * should call the methods with different arguments and print out results. You * should think about different arguments to try that tests 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 false result. Use print statements * to explain what each test is checking and the result that was obtained. The * assignment gives a small example of this. Running this program should output * a small report on examples of using the different methods. * * Replace this comment with your own Javadoc comment */ public static void main(String[] args) { // Add tests here }

/**

* Produces a String starting and ending with the edge character and having the * inner char repeated in-between. The total number of characters in the string * is width. As an example makeLine('+', '-', 8) would return the string * "+------+". * * NOTE: This method is already completely implemented and must not be modified * for the assignment. * * @param edge The character used at the start and end of the returned string. * @param inner The character repeated in-between the edge char. * @param width The total number of characters in the returned 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 line first. while (currentLocation < width - 2) { line = line + inner; currentLocation = currentLocation + 1; } // Add in the start and end character to the line. return edge + line + edge; }

/** * Returns a string which, when printed out, will be a square shaped like this, * but of varying size (note - even though there are the same number of * characters side-to-side as up-and-down, the way text is drawn makes this look * not like a square. We will consider it a square.): * *

 * +-----+ * | | * | | * | | * | | * | | * +-----+ * 
* * The returned string should consist of width lines, each ending with a * newline. In addition to the newline, the first and last 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 one string to be on multiple * lines. System.out.println("Hi There"); will produce output like Hi There * * The ' ' character is a newline. * * The method does not print anything. * * The width parameter must be greater than or equal to 2. * * You should use while, if, and else statement. * * IMPLEMENTATION NOTE: For full credit (and for easier implementation), make * use of the makeLine method provided above in your implementation of * makeRectangle. You'll need to use a loop to call makeLine the correct number * of times. * * Replace this comment with your own Javadoc comment */ public static String makeSquare(int width) { return ""; // Replace this line with your own code. } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Assessment of skills and interests.

Answered: 1 week ago

Question

Psychological, financial, and career counseling.

Answered: 1 week ago