Create a program “MethodTests" which will contain a number of methods all called from the main method. 1) Method 1: - Takes 1 String parameter - Prints out "Hello" + the String argument 2) Method 2: - Requests an int and a String input from the user and stores them in local variables in main() - Create a method which takes these two values as parameters - Call a Math library method of your choice (like Math.abs(int i) or Math.exp(int i) or something else) with the int parameter value in your method and print the result of it along with the String you passed in. Example: Say int num entered by user is -10 And String str entered by user is "Fairfield" Then if you use Math.abs(num), then output would be: "10 Fairfield" 3) Method 3: - Requests two double values from the user and stores them in local variables in main() - Create a method which takes these two values as parameters - The method will use Math library functions to: o Print the square root of the 1st parameter o Print the log of the 2nd parameter o Print the value of the 1st parameter raised to the power of the 2nd parameter
Why is my second method not executing correctly? Also, help regarding third method is appreciated.
package assignments;
import java.util.Scanner;
public class Assignment4 {
public static void main(String[] args) {
MethodTests("");
int randomNum1 = (int) (Math.random() * 100);
System.out.println("I am thinking of a number between 1 and 100. can you figure out what it is?");
Scanner input = new Scanner(System.in);
int number = input.nextInt();
System.out.println("Your guess was " + number);
if (number == randomNum1) {
System.out.println("The number I was thinking of was" + randomNum1);
System.out.println("Your guess was correct!");
} else {
System.out.println("The number I was thinking of was " + randomNum1);
System.out.println("Your number was incorrect :(");
}
String yourstring = input.nextLine();
int firstint=input.nextInt();
String stringy = input.nextLine();
MethodTests(yourstring);
MethodTests2(firstint, stringy);
//MethodTests3();
}
public static void MethodTests(String yourstring){
System.out.println("Input your string");
Scanner input = new Scanner(System.in);
yourstring = input.nextLine();
System.out.println("Hello " + yourstring);
}
public static void MethodTests2(int firstint, String stringy){
System.out.println("Enter an int");
Scanner input = new Scanner(System.in);
firstint = input.nextInt();
System.out.println("Enter a String: ");
stringy =input.nextLine();
System.out.println(" Math.abs =" + Math.abs(firstint) + stringy);
}
// public static void MethodTests3(){
//}
}
![Create a program "MethodTests" which will contain a number of methods all called from the main
method.
1) Method 1:
- Takes 1 String parameter
- Prints out "Hello" + the String argument
2) Method 2:
- Requests an int and a String input from the user and stores them in local variables in
main()
- Create a method which takes these two values as parameters
- Call a Math library method of your choice (like Math.abs(int i) or Math.exp(int i) or
something else) with the int parameter value in your method and print the result of it along
with the String you passed in.
Example:
Say int num entered by user is -10
And String str entered by user is "Fairfield"
Then if you use Math.abs(num), then output would be:
"10 Fairfield"
3) Method 3:
- Requests two double values from the user and stores them in local variables in main()
- Create a method which takes these two values as parameters
- The method will use Math library functions to:
o Print the square root of the 1st parameter
o Print the log of the 2nd parameter
o Print the value of the 1st parameter raised to the power of the 2nd parameter](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe47c4bd6-568c-4770-a86e-93574933d968%2F66619084-e401-4dcf-b513-0ce38102e591%2Fw9v221n_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)