我也刚学不久,试了一下:
import java.lang.Math;
import java.lang.Double;
public class fangchen
{
public static void main(String args[])
{
double a,b,c,result1,result2;
a=Double.parseDouble(args[0]);
b=Double.parseDouble(args[1]);
c=Double.parseDouble(args[2]);
if((b*b-4*a*c)<0)
System.out.println("There is no gen,Please Input again"+"\n");
else
{ result1=(-b+Math.sqrt(b*b-4*a*c))/(2*a);
result2=(-b-Math.sqrt(b*b-4*a*c))/(2*a);
System.out.println("result1="+result1+"\n"+"result2="+result2);
}
}
}
请不要见笑...
[此贴子已经被作者于2006-4-4 14:52:24编辑过]