go to previous page   go to home page   go to next page hear noise

Why is this loop a sentinel-controlled loop?

Answer:

The sentinel value "n" terminates the loop.


Reading in x

Here is the program, with some work done on reading a value for x.


import java.util.Scanner;

class EvalPoly
{
  public static void main (String[] args )  
  {
    Scanner scan = new Scanner ( System.in );

    double x;                      // a value to use with the polynomial
    String response = "y";         // "y" or "n"

    while ( response.equals( "y" ) )    
    {
       // Get a value for x.
       System.out.println("Enter a value for x:") ;
       x = scan.;

       // Evaluate the polynomial.

       // Print out the result.

       // Ask the user if the program should continue.
       System.out.println("continue (y or n)?");
       response = scan.next();      
    }

  }
}

QUESTION 19:

Fill in the blank.