troubleshooting Question

Where is my math error?

Java
I am trying to find the square root of 1000. I know my problem is in my math somewhere. I have treid a lot of stuff today but very little works.  Please provide some ideas of where I am making my mistake. This is classwork but to be honest I am about ready to turn it in as it is.

I NEED THE OUTPUT
Finding the square root of:1000

Pass:1 Est = 500.500000
Pass:2 Est = 251.249001
Pass:3 Est = 127.614558
Pass:4 Est = 67.725327
Pass:5 Est = 41.245426
Pass:6 Est = 32.745269
Pass:7 Est = 31.642016
Pass:8 Est = 31.622782
Pass:9 Est = 31.622777
Pass:10 Est = 31.622777
Pass:11 Est = 31.622777
Pass:12 Est = 31.622777
Pass:13 Est = 31.622777
Pass:14 Est = 31.622777
Pass:15 Est = 31.622777
Pass:16 Est = 31.622777

The square root of 1000 is 31.622777

I AM GETTING THIS AS A OUTPUT
Finding the square root of:1000

Pass:1 Est = 1000.000000
Pass:2 Est = 501.000000
Pass:3 Est = 252.496008
Pass:4 Est = 130.208463
Pass:5 Est = 72.784224
Pass:6 Est = 50.131353
Pass:7 Est = 45.013273
Pass:8 Est = 44.722306
Pass:9 Est = 44.721360
Pass:10 Est = 44.721360
Pass:11 Est = 44.721360
Pass:12 Est = 44.721360
Pass:13 Est = 44.721360
Pass:14 Est = 44.721360
Pass:15 Est = 44.721360
Pass:16 Est = 44.721360

The square root of 1000 is 44.721360
Process completed.

class squareRoot1

{
public static void main(String args[])
{
int n = 1000;
double est = n;
est = n;
System.out.println("Finding the square root of:"+n);
System.out.println("");

for(int i = 1; i < 17; i++)

{
System.out.printf("Pass:"+i+" Est = %1.6f\n",est);
est = (n/est)+est/2;
}
System.out.println("");
System.out.printf("The square root of 1000 is %1.6f",est);
}
}
Thomas4019
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.