1.60 米 转换Height:Ft In

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 17:38:19
1.60米转换Height:FtIn1.60米转换Height:FtIn1.60米转换Height:FtInclassConvert{publicstaticfinalintM=1;publicsta

1.60 米 转换Height:Ft In
1.60 米 转换Height:Ft In

1.60 米 转换Height:Ft In
class Convert{
public static final int M=1;
public static final int DM=2;
public static final int CM=3;
public static ImperialLength toImperial(double length,int unit){
switch(unit){
case M:length/=0.0254;break;
case DM:length/=0.254;break;
case CM:length/=2.54;break;
default:return null;
}
int inches=(int)(Math.round(length/2.54));
return new ImperialLength(inches/12,inches%12);
}
public double toMetric(int feet,int inch){
return (feet*12+inch)*0.0254;
}
}
class ImperialLength{
public int feet;
public int inch;
public ImperialLength(int feet,int inch){
this.feet=feet;
this.inch=inch;
}
}