See below.
Here is the program with the details for reading a value for x filled in:
import java.io.*; class evalPoly { public static void main (String[] args ) throws IOException { BufferedReader userin = new BufferedReader(new InputStreamReader(System.in) ); String xChars; // character version of x, from the user double x; // a value to use with the polynomial double result; // result of evaluating the polynomial at x String response = "y"; // "y" or "n" while ( response.equals( "y" ) ) { // prompt the user and get a value for x System.out.println("Enter a value for x:") ; xChars = userin.readLine() ; x = ( Double.valueOf( xChars ) ).doubleValue(); // evaluate the polynomial result = ______________________________ ; // print out the result ________________________________________ ; // ask the user if program should continue System.out.println("continue (y or n)?"); response = userin.readLine(); } } } |
Remember what the problem is: You are interested in the value of the polynomial
7x3- 3x2 + 4x - 12
for various values of x. Only two blanks remain to complete the program.