1 |
import java.io.BufferedReader; |
2 |
import java.io.InputStreamReader; |
3 |
import java.io.IOException; |
4 |
|
5 |
/** |
6 |
This program computes square roots of inputs supplied |
7 |
through System.in |
8 |
*/ |
9 |
public class RootApproximatorTest3 |
10 |
{ |
11 |
public static void main(String[] args) |
12 |
throws IOException |
13 |
{ |
14 |
BufferedReader console |
15 |
= new BufferedReader(new InputStreamReader(System.in)); |
16 |
boolean done = false; |
17 |
while (!done) |
18 |
{ |
19 |
String input = console.readLine(); |
20 |
if (input == null) done = true; |
21 |
else |
22 |
{ |
23 |
double x = Double.parseDouble(input); |
24 |
RootApproximator r = new RootApproximator(x); |
25 |
double y = r.getRoot(); |
26 |
|
27 |
System.out.println("square root of " + x |
28 |
+ " = " + y); |
29 |
} |
30 |
} |
31 |
} |
32 |
} |