文件的主要方法:主要问题是double celciustofahrenheit等在数据传入后不返回计算结果,这是一个恒定的流,就像我想返回main并再次提示用户输入和缩放选择,这是一个switch case语句,它根据所选内容输出缩放信息已传递到inputemp,但即使无法输出
public double inputTemp(int scale) {
Scanner localInput = new Scanner(System.in);
System.out.println("enter temperature to convert \n"
+ "please numeric data only");
double celciusToFahrenheitCall = cToF(inputField.nextDouble());
double kelvinToCelciusCall = kToC(inputField.nextDouble());
double fahrenheitToCelciusCall = fToC(inputField.nextDouble());
double kelvinToFahrenheitCall = kToF(inputField.nextDouble());
double celciusToKelvinCall = cToK(inputField.nextDouble());
double fahrenheitToKelvinCall = fToK(inputField.nextDouble());
return scale;
}
double cToF(double inputField) {
inputField = (9/5 * inputField + 32);
return inputField;
//converts Celsius to Fahrenheit and returns the answer
}
double kToF(double inputField) {
double kelvinToFahrenheit = (9/5 * inputField - 273 + 32);
return kelvinToFahrenheit;
//converts Kelvin to Fahrenheit and returns the answer
}
double fToC(double inputField) {
return (5/9 * (inputField - 32));
//converts Fahrenheit to Celsius and returns the answer
}
double cToK(double inputField) {
return (inputField + 273);
//converts Celsius to Kelvin and returns the answer
}
double kToC(double inputField) {
return (inputField - 273);
//converts Kelvin to Celsius and returns the answer
}
double fToK(double inputField) {
return ((5/9 * (inputField -32 ) + 273));
//converts Fahrenheit to Kelvin and returns the answer
}
}
暂无答案!
目前还没有任何答案,快来回答吧!