我試圖對第二個返回方法進行兩個調用,該方法需要一個參數(以英寸爲單位),並以釐米爲單位打印該值,但不工作!我做了什麼錯`Java方法代碼錯誤
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// prompt the user and get the value
System.out.print("Exactly how many inches are you? ");
int uHeight = in.nextInt();
// converting and outputing the result
System.out.print("How many inches is your mother? ");
int mHeight = in.nextInt();
InchesToCm(mHeight,uHeight);
}
public static double InchesToCm() {
Scanner in = new Scanner(System.in);
System.out.print("Exactly how many inches are you? ");
int inHeight = in.nextInt();
double cmHeight = inHeight * 2.54;
System.out.println("He's " + uHeight + " inches or " + mHeight + " cm.");
return
請更準確地說,是如何它不工作? – Berger
什麼問題,例外,錯誤?請用這些信息編輯問題。見[問]。那麼,我沒有看到'InchesToCm'方法中的返回值,但沒有右括號。那麼它是完成方法? – AxelH