abstract class Supchange
{
double h;
double s;//为什么float不行?
Supchange(double h1,double s1)
{
h=h1;
s=s1;
}
abstract double conver();
}
class SubchangeH extends Supchange
{
SubchangeH(double h1,double s1)
{
super(h1,s1);
}
double conver()
{
double sum=s*9/5+32;
return sum;
}
}
class SubchangeS extends Supchange
{
SubchangeS(double h1,double s1)
{
super(h1,s1);
}
double conver()
{
double sum=(h-32)*5/9;
return sum;
}
}
public class ConversionTest
{
public static void main(String [] args)
{
double hs;
double ss;
SubchangeH she=new SubchangeH(98.6,100);
SubchangeS hua=new SubchangeS(98.6,100);
hs=hua.conver();
ss=she.conver();
System.out.println(she.s);
System.out.println(ss);
System.out.println(hua.h);
System.out.println(hs);
}
}
这里我把所有的double换成float为会么出错?
请大家帮忙,谢谢!
[求助]一个小程序不太懂!