Example Dialog

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:

The loop (and the program) stops because the user did not type "y".

Example Dialog

The program is not as user friendly as we would like. It insists that the user enter exactly "y" to continue. This problem could be fixed with a few extra statements. But let's not. Here is a sample user dialog with the program:

C:/users/default/JavaLessons/chap18>java EvalPoly

Enter a value for x:
-1
The value of the polynomial at x = -1.0 is :-26.0

continue (y or n)?
y
Enter a value for x:
1
The value of the polynomial at x = 1.0 is :-4.0

continue (y or n)?
y
Enter a value for x:
1.178
The value of the polynomial at x = 1.178 is :-0.008209736000004852

continue (y or n)?
yes

C:/users/default/JavaLessons/chap18>

QUESTION 22:

At about what value for x does the polynomial evaluate to zero?