浮点数怎么不能正确的输出呢????
class YiWai
{public static void main(String[] args){
double rs;
final int LEN=20;
byte[] temp1=new byte[LEN];
try
{
System.out.print("input x : ");
System.in.read(temp1,0,LEN);
}
catch (Exception e){}
String xtemp=new String(temp1);
int x=new Integer(xtemp.trim()).intValue();
//the first number!
byte[] temp2=new byte[LEN];
try
{
System.out.print("input y : ");
System.in.read(temp2,0,LEN);
}
catch (Exception e){}
String ytemp=new String(temp2);
int y=new Integer(ytemp.trim()).intValue();
if (x==y)
{System.out.print("error");
}
else{
rs=(x+y)/(x-y);
System.out.print("rs is "+rs);
}
}
};
输出是有小数的
但是小数位置总是零!