Question: 5. Write a static method f(n) in the space provide, that returns O if n is even, and if n is odd, returns 1 or

5. Write a static method "f(n)" in the space provide, that returns O if n is even, and if n is odd, returns 1 or -1 according as n is greater than or less than 0. importjava.util.Scanner; public class Q_05 Your "f(n)" method: public static void main(String args[]) mana int n; Scanner input = new Scanner(System.in); System.out.print("Please enetrn: "); n=input.nextInt(); System.out.println(f(n)); "Method f(n)" 7. Write a static method "max" in the space provide, that returns the maximum value from 3 input integers. import java.util.Scanner; public class Q_08 Your "max" method: public static void main(String args) int x, y, z, maximum; Scanner scan = new Scanner(System.in); System.out.print("Enter x, y, z: "); x = scan.nextInt(); y = scan.nextInt(); z = scan.nextInt(); maximum = max(x, y, z); System.out.print("The max is:" + maximum); "Method max
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
