我正在尝试制作一个转换器,它可以将其他单位转换为脚,它只是在韦小宝中一直运行,当我使用其他java刺激器时,其中一些在线程“main”java.util.nosuchelementexceptio中显示错误异常,而另一些则一直在运行。我不知道你能不能把这根绳子插进去。
import java.util.Scanner;
public class Converter{
private double micrometer = 304796.293632;
private double millimeter = 304.79629363199995851;
private double centimeter = 30.479629363199993719;
private double meter = 0.30479629363199994829;
private double kilometer =0.00030479629363199992704 ;
private double foot;
public Converter(double Ft){
foot = Ft;
}
public double calculateMicro(){
return foot * micrometer;
}
public double calculateMilli(){
return foot * millimeter;
}
public double calculateCenti(){
return foot * centimeter;
}
public double calculateMeter(){
return foot * meter;
}
public double calculateKilo(){
return foot * kilometer;
}
public static void main(String argv[]){
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
int x = 1;
int option = sc.nextInt();
//what I think the error area
while(x==1){
if(option==1){
System.out.println("1.micrometer 2.millimeter 3.centimeter 4.meter 5. kilometer");
Converter converter1 = new Converter(input);
System.out.println(converter1.calculateMicro());
}
else if(option==2){
Converter converter2 = new Converter(input);
System.out.println(converter2.calculateMilli());
}
else if(option==3){
Converter converter3 = new Converter(input);
System.out.println(converter3.calculateCenti());
}
else if(option==4){
Converter converter4 = new Converter(input);
System.out.println(converter4.calculateMeter());
}
else if(option==5){
Converter converter5 = new Converter(input);
System.out.println(converter5.calculateKilo());
}
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!