nethod. ) Method 1: - Takes 1 String parameter - Prints out "Hello" + the String argument ) 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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

This is what I have so far. How do I go about finishing the prompt. How does one use a Math library method?

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
Transcribed Image Text: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
23
24
25
}
26
MethodTests(yourstring:"");
27
MethodTests2(input.nextInt(), input.nextLine());
28
MethodTests3();
String yourstring;
int firstint= input.nextInt();
String stringy = input.nextLine();
29
30
31
32
This is in the main method.
33
34
35
36
public static void MethodTests (String yourstring){
System.out.println("Input your string");
37
38
Scanner input = new Scanner(System.in);
String nextstring = input.nextLine();
39
40
41
System.out.println("Hello " + nextstring);
System.out.println("Input your INT followed by a STRING:");
42
43
44
45
46
47
48
}
49
public static void MethodTests2(int firstint, String stringy){
50
51
Scanner input = new Scanner(System.in);
System.out.println("Your int is: " + firstint);
System.out.println("Your string is: " + stringy);
52
53
54
55
56
57
58
-D
HD
Transcribed Image Text:23 24 25 } 26 MethodTests(yourstring:""); 27 MethodTests2(input.nextInt(), input.nextLine()); 28 MethodTests3(); String yourstring; int firstint= input.nextInt(); String stringy = input.nextLine(); 29 30 31 32 This is in the main method. 33 34 35 36 public static void MethodTests (String yourstring){ System.out.println("Input your string"); 37 38 Scanner input = new Scanner(System.in); String nextstring = input.nextLine(); 39 40 41 System.out.println("Hello " + nextstring); System.out.println("Input your INT followed by a STRING:"); 42 43 44 45 46 47 48 } 49 public static void MethodTests2(int firstint, String stringy){ 50 51 Scanner input = new Scanner(System.in); System.out.println("Your int is: " + firstint); System.out.println("Your string is: " + stringy); 52 53 54 55 56 57 58 -D HD
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY