Question: Homework 5 Java language Q1: Write a method for each of the following: 1. Method hypotenuse that takes two double precision arguments, side1 and side2.

 Homework 5 Java language Q1: Write a method for each ofthe following: 1. Method hypotenuse that takes two double precision arguments, side1

Homework 5 Java language Q1: Write a method for each of the following: 1. Method hypotenuse that takes two double precision arguments, side1 and side2. Then calculates the hypotenuse (use the following equation), and returns a double precision floating point result. hypotenuse = sidel? + side22 2. Method floatRound that takes a double argument, number, then round it. Then, print the result. (Hint: use rounding methods in Math class). 3. Write a java program that asks the user to input two double numbers s1 and s2 (sides of a right tringle), then find the hypotenuse h (Use the method in 1). Then print the value of h after rounding it (Use the method in 2 floatRound to round h). (3x10=30 points) Q2: Identify and correct the error in each of the following codes: 1. int sum( int x, int y ) { int result; result = x + y; } 2. double product ( void ) { int a = 6, b = 5, c = 4, result; result = a + b * c; System.out.printf ("Result is %d", result); return result; } 3. class MyClass { public static void main(String[] args) { int x; System.out.println("Begin Main"); x=test (x); System.out.println("End Main"); 1 static float test() { System.out.println("Inside Test("); return 10; } } Q3: Complete the missing statements in the following Java program, then show the output? (20 points) a. class MyMethod { static funcl (int i) { System.out.println("i=" + i++); System.out.println("i=" + ++i); } public static void main(String[] args { int x=0; // call method System.out.println("x="+ }}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!