Questions 15 Total 5 please answer all 5 questions 175 edhes

Questions 1-5
Total 5 please answer all 5 questions
175 edhesive Term 1 Unit 4 Week 14 worksheet. Return Methods For each of the following method headers complete the methodso that it works as intended. Hint: Many of these will use cmod) publie static boolean salven tint true if it is an Pass in a teger and retur and ret rn false if it is not publie static int round It (double al rounded version of the parameter Pass in a double and retu So 4.6 would return 5 and 6.2 would retur Find the mistakes in the following methods: public static void mystery (int a) public static double mystery (double a) System-out print in (a 14) public static int mystery (int a) if (a 70) return 1: Term 1 Unit 4 Week 14 Version 1.19 Edhesive

Solution

1.
public static boolean isEven(double a)
   {
   if(a%2==0) //i.e no remainder
       return true;
   else
       return false;
   }

2.
public static int roundIt(double a)
   {
   return (int) a; //use typecasting to convert double to int
   }


3.
The function returns a integer but in defenition of function return type is void so it can\'t return aything. That generates a compilation error.

4.
The function has a return type double but there is no return statement in function.

5.
The function has a return type int but if the parameter a is less than equal to 70 then there is nothing returns from the function.

Questions 1-5 Total 5 please answer all 5 questions 175 edhesive Term 1 Unit 4 Week 14 worksheet. Return Methods For each of the following method headers comple

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site