我正在编写一个将公里转换为英里的 java 程序。我的代码是:
public class Ex7Program {
public void start() {
String userKilometres;
double kilometres = getKilometresFromUser();
double miles = convertKilometresToMiles(kilometres);
printResult(kilometres, miles);
}
private double getKilometresFromUser() { // Insert your 3 methods here.
System.out.print("Enter kilometres: ");
String userKilometres = Keyboard.readInput();
double kilometres = Double.parseDouble(userKilometres);
return kilometres;
}
private double convertKilometresToMiles(double kilometres) {
double miles = 0.621371 * kilometres;
return miles;
}
private void printResult(double kilometes, double miles) {
System.out.print(kilometres + " Kilometres is " + miles + " miles ");
}
}
我在打印结果的最后一条语句中遇到错误,它说:
Error: kilometres cannot be resolved to a variable
我花了很长时间尝试修复它,经过多次失败尝试后我决定来这里。有什么建议我哪里出错了吗?帮助将不胜感激。