The complete program is given below.
Translating the polynomial
7x3- 3x2 + 4x - 12
into Java is easy.
The term x3
means x
times itself three times,
so that is what the Java statement does.
The integers in the expression (such as the 7) will automatically
be converted to double
, so the entire calculation will be
done with double precision.
The next statement
writes out the answer.
The +
operator concatenates the strings.
Remember that doubles are converted to strings automatically when you
use +
between a double and a string.
What happens in this program if the user types "yes" in response to the prompt continue (y or n)?