1. Engineering
  2. Computer Science
  3. in this assignment youll be using what youve learned about...

Question: in this assignment youll be using what youve learned about...

Question details

In this assignment youll be using what youve learned about Java to implement a library of static methods. Please read and follow the directions carefully! In your assignment project, add a package a2. Import starter code from this Google Drive file https://drive.google.com/file/d/1dP9r4RlvlwlXEX4kXbwrKxFBXB3S7CNp/view?usp sharing e It contains method stubs (the signature and a method body which returns some default result) and comment descriptions of several methods for you to implement as well as an already implemented method to help you for one problem. The method stubs are precisely specified in their comments and/or method headers. Your job is to implement the methods so that they adhere to their specifications. These methods will exercise much of what youve learned about Java. You will be using primitive values (such as ints, booleans, and chars) and objects (such as Strings and Scanners). Youll be using lots of different kinds of expressions. Youll be using a variety of statements, such as variable declarations, assignments, while loops, conditionals, and returns Be sure to add your name as the author to the Javadoc comment associated with the class. The comment on each method you implement should be replaced with a more formal Javadoc comment using @param and @return tags. Notice how I have chosen descriptive names for all classes, methods, and variables. If you want full credit, you should do the same with your code. Notice how my code is nicely formatted. Your code should be nicely formatted too. (If you type ControlOrCommand-Shift-F Eclipse will format your code for you.) You will almost certainly find this more challenging than A1. Some of the methods require you to be very comfortable with things like substring and joining strings together with +. Some of them are quite short but you will need to be clever about how to solve the problem. Others will need you to look up certain Java operations so that you can use them comfortably. Please start early so that youll have time to think and ask questions when you get stuck. Starting on Wednesday or Thursday is a recipe for failure. You will also notice from reading the comments that you need to add code to main. This is mostly for your benefit - you need to call your implemented methods to see if they work. But, provide output and descriptions that explain what is going on. For example, your main method might call want to test countTokens(l am David). Your code might have String testString-I am David; int numberOfTokens countTokens(testString); System.out.println(countTokens found numberOfTokens+on test input: + testString); When you run your program with more of these tests, you would see a sequence of these reports on the method behavion Submitting To turn in your program for grading, upload the .java file to assignment 2 in Gradescope. You will see a number of tests pass or fail. Additional tests and TA evaluate will happen after the due date You can upload a solution as many times as you like, but we will only grade your most recent submission. his tool needs to be loaded in a new browser windowReturns a string literal negative if the parameter is less than zero and equal to zero For example, the method call deacribeSign should return non-negative You should use an if statement You must return these strings exaczly (all lower case letters, spelled denote a string literal, they do not appear in the actual string Do not print the string return value * returns the string literal non-negative if th value is greater than or *correctly, no extra spacesAlso note that the double quotes are used to * Replace this comment with your own Javadoc comment public static String deacribeSign (int value // Chang or modify the return. This is herв for now to prevent comp iler errors return ; Returns irue if the value parameter is evenly divisible by7 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 modu-u8 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 abou: modulus is * https:/ww.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/what-is-modular-arithmetic * Replace this met with your own Javaiac comment public static boo1ea n İsRvenlyDivisibleBySeven(int value) / Change or modify the return. This ia here for now to prevent compiler errora return true; *Returns a String of length width that begins and ends with the character edge *and contains width-2 copies of the character inner in between. For example, * if edge is +inner is -*, and width is 8, the method should return The method does not print anything. The parameter width must be greater than or equal to 2 IMPLEMENTATION NOTE: This method is already completely implemented. There is dd your ow Javadoc comment * no need for you to change anything in the code public static String make. ine(Cha r edge, cher inner, int width) { String line - int i =0; while (i < width 2) [ lineline inner i-i +1 retur edge line edge; Returns a string which, when printed out, wll be a square shaped like this, *but of varying size: pre </pre> The returned string should consist of width linea, each ending with awhile i<width- 2) I line line inner i-i 1; return edge lineedge; *Returns a string which, when printed out, will be a square shaped like this, *but of varying size: pre> 、/pre> * 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 1 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 *o equal to 2. You do not need to check this, you can assume it IMPLEMENTATION NOTE: For full credit (and for easier implementation), make *use of the makeLine method in your implementation of makeSquare. You1l *need to use a loop to cal1 makeLine the correct number of tines Replace this comment with your own Javadoc comment public static String makeSquare (int width) return *Returns the string that results from capitalizing the last character of word, *which is required to have at least one character. For example, * capitalizeLastCharacter(hello) is hello and capital izeLastCharacte r { JACK 》 İS JACK * IMPLEMENTATION NOTE: The static method Character.toUpperCase() will be helpful. The methods s.charAt and s.substring [where s is a String] will * also be helpful. * Since Strings are immutable, you cannot just change the last character. Think *about breaking the given string into pieces, modifying the last part and then * building up a new String in the correct form *Replace this comment with your own Javadoc comment public static String capitalizeLastCharacter(String word) I Change or remove this statement as needed return; Returns the string that results from capitalizing the last character of every * word in the input parameter sentence, which is required to have at least one * character. For example, capitalizeLastcharactersInSentence (Hello there * would retun Hello therE. You can assume that the sentence is a basic * English-style sentence with a singie space between words Replace this corment with your ow Javadoc coment public static String capitalizeLastcharactersInSentence (String sentence) 1 Change or remove this statement as needed return;

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution