我正在尝试制作一种将任何单位转换为任何大单位的方法。我需要,我猜为每个输入提供参数,所以我猜测它需要询问用户参数....startingNum,conversionFactor,outPutNum,但我不确定从哪里开始。我已经用英寸做了一个:Java - 将任何单位转换为任何单位
public Convertor()
{
inches=0;
feet=0;
yards=0;
leftoverInches=0;
}
/**
* Mutator method to convert inches to feet
*/
public void convertValuesInchtoFeet(int anyInches)
{
inches=anyInches;
feet=anyInches/12;
leftoverInches= anyInches%12;
System.out.println(inches+" inches = " +feet+" feet.");
System.out.println("There are " +leftoverInches +" leftover inches");
}
请帮忙!谢谢。
好像你需要枚举(http://download.oracle.com/javase/tutorial/java/javaOO/enum.html)。 – 2011-03-24 19:38:28
@user:也许你应该在提交反馈给你的[上一个问题](http://stackoverflow.com/questions/5424390/convert-feet-to-inches)之前,转到新的?顺便说一下,如果您在20分钟后忘记了用户名,它就是[jtm22](http://stackoverflow.com/users/675495/jtm22)。 – 2011-03-24 19:41:12
试着想办法从你以前的问题推广:http://stackoverflow.com/questions/5424350/convert-feet-to-inches – Feanor 2011-03-24 19:41:38