求解平方根
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args)throws IOException{
if(false){
return ;
}else{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str =null;
do{
str=br.readLine();
if(str!=null){
double d =new Main().run(str);
String tempD=Double.toString(d);
tempD=tempD.substring(0,4);
int last=Integer.parseInt(tempD.substring(3,4));
if(last>=5){
d+=0.1;
}
tempD=Double.toString(d);
tempD=tempD.substring(0,3);
System.out.println(tempD);
}
}while(str!=null);
}
}
public double run(String str){
double num=Double.parseDouble(str);
double dis=1.0;
double start=0.1;
for(double i=0.1;dis>0.0;i+=0.01){
double temp=i*i*i;
dis=num-temp;
start=i;
}
return start;
}
}
--------------------------------
public class demo02{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("请输入一个数:");
double a;
a=s.nextDouble();
double b=Math.cbrt(a);
System.out.println(a+"的立方根为:"+b);
}
}