1 |
import javax.swing.JOptionPane; |
2 |
|
3 |
/** |
4 |
This program prints ten approximations for a square root. |
5 |
*/ |
6 |
public class RootApproximatorTest |
7 |
{ |
8 |
public static void main(String[] args) |
9 |
{ |
10 |
String input |
11 |
= JOptionPane.showInputDialog("Enter a number"); |
12 |
double x = Double.parseDouble(input); |
13 |
RootApproximator r = new RootApproximator(x); |
14 |
final int MAX_TRIES = 10; |
15 |
for (int tries = 1; tries <= MAX_TRIES; tries++) |
16 |
{ |
17 |
double y = r.nextGuess(); |
18 |
System.out.println("Guess #" + tries + ": " + y); |
19 |
} |
20 |
System.exit(0); |
21 |
} |
22 |
} |