Question
Please help me. package tester; public class ExampleMethods { /* * Instructions for students: Use the main method only to make calls to the *
Please help me.
package tester;
public class ExampleMethods {
/* * 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 }
/** * Returns a string literal "negative" if the parameter is less than zero and * returns the string literal "non-negative" if the value is greater than or * equal to zero. * * For example, the method call describeSignOfNumber(7) should return * "non-negative". * * You should use an if statement. * * You must return these strings exactly (all lower case letters, spelled * correctly, no extra spaces). Also note that the double quotes are used to * denote a string literal, they do not appear in the actual string. * * Do not print the string return value. * * Replace this comment with your own Javadoc comment * */ public static String describeSignOfNumber(int value) { return ""; // Replace this line with your own code. }
/** * Returns a string literal "negative" if the parameter is less than zero, * "zero" if the parameter is zero, and "positive" if the number is greater than * zero. * * For example, the method call classifyNumber(7) should return "positive". * * You must return these strings exactly (all lower case letters, spelled * correctly, no extra spaces). Also note that the double quotes are used to * denote a string literal, they do not appear in the actual string. * * Do not print the string return value. * * Replace this comment with your own Javadoc comment * */ public static String classifyNumber(int value) { return ""; // Replace this line with your own code. }
/** * Returns true if the value parameter is evenly divisible by 7 and false * otherwise. * * For example, the method call isEvenlyDivisibleBySeven(14) should return true. * The method call isEvenlyDivisibleBySeven(16) should return false. * * You will want to use the modulus operator %, which evaluates to the remainder * of x/y. When the remainder is 0, x is evenly divisible by y. * * A starting point for learning about modulus is * https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/what-is-modular-arithmetic * * Replace this comment with your own Javadoc comment */ public static boolean isEvenlyDivisibleBySeven(int value) { return false; // Replace this line with your own code. }
/** * Returns the larger of the two parameter values. For example, * chooseLargest(10.0, 100.0) should return 100.0. You must use an if statement * and not some kind of built in Java max function. * * Replace this comment with your own Javadoc comment */ public static double chooseLargest(double number1, double number2) { return 0.0; // Replace this line with your own code. }
/** * This method takes the start number and doubles it (times 2) while the number * is less than or equal to 100. As soon as it is bigger than 100, that value is * returned. * * For example, firstDoublingPastOneHundred(5) would return 160. The internal * sequence of numbers produced would be 5, 10, 20, 40, 80, 160. * The input parameter must be a positive number. You do not need to check this. * * Replace this comment with your own Javadoc comment */ public static int firstDoublingPastOneHundred(int startNumber) { return 0; // Replace this line with your own code. }
/** * Given a String sentence, returns a String made of every other letter from * sentence, starting with the first character. If the sentence is the empty * string, return the empty string. * * For example, everyOtherLetter("David is cool") would return "Dvdi ol". * * Replace this comment with your own Javadoc comment */ public static String everyOtherLetter(String sentence) { return ""; // Replace this line with your own code. }
/** * 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. * * 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started