这是作业:(编写一个程序,该程序从控制台读取一个双精度学位,然后将其转换为华氏度并向用户显示结果。转换的公式为:华氏=(9/5)*摄氏+ 32)。问题是我似乎无法获得十进制数字,只能获得四舍五入的版本。
这是我的代码:
package JavaLearningSections;
import java.util.Scanner;
public class Assignment1Nr3 {
public static void main (String[]args) {
System.out.println("Enter the temperature in degree to turn it to Fahrenheit");
Scanner input = new Scanner(System.in);
double numDegree = input.nextDouble();
double numFahrenheit = (9/5 *numDegree)+32;
System.out.println(numFahrenheit);
}
}
double numFahrenheit = ((double)9/5 * numDegree) + 32;