Reading the User's Response

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

No. A better program would test for this response, also.

Reading the User's Response

Here is the program with some additional work done on the "prompting and looping" aspect:

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

       // Evaluate the polynomial

       // Print out the result

       // Ask the user if the program should continue.
       // The user's answer is "response".
       ;

       response = scan.;      
    }

  }
}


QUESTION 17:

Fill in the blanks.