Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hi please answer each part of this code There is a class with 12 methods. Methods are called part1, etc. The body of each method
hi please answer each part of this code
There is a class with 12 methods. Methods are called part1, etc. The body of each method has comments that explain what the method needs to return. Your job is to write code to make sure it returns the correct value. There are tests you can run that will verify your method is working properly. Your grade will be determined by how many tests you pass. Each test or part is worth 5 points, for a total of 60 . public class Main \& public int parto(int lhs, int rhs) \{ I/ Complete this method such that returns the sum of the two interger arguements. 1/ This method as already been implemented for you as an exanple - int sum = ths + rhs; // finding out the sum return sum; // and then returning it h public String part10 f 1/ Declare a String variable, name it student and assign it the value "Matcolm." 1/ once you are done, return the string variable you created on the fotlowing line - I/ hint: return NAME_OF_VARIABLE; return ""; 1 public int part2lint ths int rhs) f 1/ Complete this method so it returns out the remainder of the two paraneters. 1/ hint: int result = ??? I/ hint: and then: return result;? public int part3(int ihs int rhs) \& 1/ Complete this method so it returns the quotient of the two parameters. public int part4(int lhs, int rhs) \{ // Complete this method so it returns the product of the two parameters. \} public String part5(String lhs, String rhs) \& I/ Complete this method to return the two String parameters combined (concatenated) together. I/ the combined string must have exactly one space (that is, this - " ") between them. 3 public String part6(long val) \& II Complete this method such that it returns the long integer value as a string, but the string II should be formatted in a nice way. I/ by nice way, I mean comma-separated; so if "val' (the arguement) is equal to '100e', the 1/ method must return "1,009" II if "val' is "12141", the method must return "12,141". I/ hint: did we learn about something called String. format()? I/ hint: you can read more at this link - I/ https://dzone. com/articles/java-string-formot-examples in: it text-The\&2enostw2ecomnont20way 20 ofq2eforma public int part7(String val) \& If Complete this method such that it returns the index of the first exclamation mark you can 1/ find in the string. /I Complete this method such that it returns the index of the first exclamation mark you can 1/ find in the string. 3 publicStringpart8(Stringval){ // Complete this method such that it returns every part of the string right I/ before the exclamation mark. If for example - If "val" is "Hetlo! How are you?", the method should 1/ return "Hello" I/ Note: all strings passed to this method witl always contain one II exclamation mark. 3 public double part9() \& /I Cooplete this method such it returns a randoh decimal value between and 1 public int partiol) & I/ Complete this nethod such it returns a random number between and 500 3 public int part11(int start int end). If Complete this method such it returns a random number between the "start" integer arguement If and the 'end' integer arguement. 7 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