/*
File: CalcSqrt.java
Description: We want to calculate the square root of a number.
Student Name: Samira Irani
Student UT EID: SI654
Course Name: CS 303E
Unique Number: 56105
Date Created: 10/06/2006
Date Last Modified: 10/06/2006
*/
import java.util.Scanner;
public class CalcSqrt
{
public static void main (String[] args)
{
Scanner sc = new Scanner (System.in);
double N = sc.nextDouble();
System.out.print ("Enter a positive number: ");
while (N < 0)
{
System.out.println ("Error! I said a positive number. Jeez. Try again.");
}
double oldGuess = N;
new double newGuess;
while (Math.abs(oldGuess - newGuess) > Math.pow(10.0,-06))
{
newGuess = ((N / oldGuess) + oldGuess / 2.0);
}
}
}