Answer to Question #310851 in Java | JSP | JSF for Jay

Question #310851

The value of y is calculated as follows:-


y = 4x3 + 2x 6 when x > 5


y = 3x2 4y + 12 when x < 5


y = 6x 5 when x = 5


Write a program that accepts the value x and then computes the value of y.

1
Expert's answer
2022-03-13T09:35:42-0400
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    System.out.println("Input x:");
    int x = scanner.nextInt();
    double y;

    if (x > 5) {
       y = 4 * Math.pow(x, 3) + 2 * Math.pow(x, 6);
    } else if (x < 5) {
        y = 3 * Math.pow(x, 2) + 12;
    } else {
        y = 6 * Math.pow(x, 5);
    }

    System.out.println("y = " + y);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS