Kate's math function

Report a typo

Here is a math function that Kate wants to use in her program:

f(x)={x2+1if   x01/x2if   0<x<1x21if   x1f(x) = \left\{ \begin{array}{ll} x^2+1 & \text{if } \text{ } \text{ } x \leq 0 \\ 1/x^2 & \text{if } \text{ } \text{ } 0 < x < 1 \\ x^2-1 & \text{if } \text{ } \text{ } x \ge 1 \end{array} \right.

The template for this function is defined below. Let's decompose it!

Your task is to create three additional methods f1, f2, and f3 for each case and complete the method f. Each method should accept x as an argument with double type.

Sample Input 1:

0.5

Sample Output 1:

4.0

Sample Input 2:

-4

Sample Output 2:

17.0
Write a program in Java 17
import java.util.Scanner;

class MultipleFunction {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double x = scanner.nextDouble();
System.out.println(f(x));
}

public static double f(double x) {
//call your implemented methods here.
}

//implement your methods here
public static double f1 ...

public static double f2 ...

public static double f3 ...
}
___

Create a free account to access the full topic