Akar Kuadrat
public class AkarKuadrat {
public static void main (String[] args){
double a=26;
double xnew=a/2;
double xold;
do{
xold=xnew;
xnew=(xold+a/xold)/2;
System.out.println("new:"+xnew);
}
while (Math.abs (xnew-xold)>1e-4);
System.out.println("AKAR DARI"+a+"="+xnew);
}
}
Outputnya
Tidak ada komentar:
Posting Komentar