Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, need some Java help, thanks 4x 3 + 8x 2 - 31x - 35 y = ------- (3x 2 + 1) 1/2 + 2

Hello, need some Java help, thanks

4x3 + 8x2 - 31x - 35

y = -------

(3x2 + 1)1/2 + 2 * | x - 1.5 |

| | means absolute value; (...)1/2 means square root

1. Your Java program should evaluate the formula shown above, starting with

x = 3 (negative 3), going up by 0.5 each time until it reaches 3.0. Therefore, your program will use these values for x: 3, 2.5, ..., 0.5, 0, 0.5, 1, ..., 2.0, 2.5, 3.0.

For each x value, the program should compute the corresponding y value. It should print these values together with explanations of what the values represent. For example, it could print the string "X = ", then the value of x, the string "Y = ", the value of y, and a message. (It is also possible to use column headings and have your numbers underneath the headings.)

The message should say one of three things (on the same line as the values):

If the value of y is exactly 0, the message should say Y IS ZERO.

If the value is positive, the message should say Y IS POSITIVE.

If the value is negative, the message should say Y IS NEGATIVE.

A typical line of output would look like this (or the values of x and y can appear underneath column headings):

X = 2 Y = 0 Y IS ZERO (actually, this one will not be zero) all on one line

Your output does not need to be formatted, but it should be readable.

2. Once you have finished using x = 3.0, the program should print a message (underneath the last line of output) saying that your first program is complete, then stop.

These are for extra credit; we havent learned how to do them yet. Make sure your program is running correctly before you add the extra credit!

1. Have your program find which of the y values is closest to 0 (either larger or smaller) without actually being equal to 0. Print the x value that gives this closest y value. Also print how close the y value is to 0.

2. Have your program count how many times the formula is positive, how many times it is negative, and how many times it is zero. Print these three values.

3. Use a printf statement to generate a neat listing of output. Print a precision of y to 4 decimal places.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions