我是一個初學者程序員(就像只有一天的舊),我想拿出代碼,將能夠使用公式f-32轉換成攝氏度,然後顯示結果。我遇到了一些麻煩,而不是顯示結果,這是什麼出現。請協助。試圖進行計算
import java.util.Scanner;
public class Assignments (
public static void main(String args[]) {
Integer Celsius, Faren;
Scanner Celsius = new Scanner(System.in);
System.out.prinln(" Enter value in Celsius: ");
int name = Celsius.nextint();
Faren = Celsius + 32;
}
}
這裏是我的結果後運行:
請你的代碼添加到這個問題,而不是它的屏幕截圖。 – Manu
主要問題是你試圖使用'Celsius'兩次的名字。 – Manu
歡迎來到StackOverflow。你必須非常小心地讓你的代碼正確,一個小錯誤,編譯器會抱怨。在編譯器發現錯誤的位置缺少'+'。此外,只是減去32是不正確的公式將攝氏轉換爲華氏。玩得開心學習編程! – Jesper