tempconverter.java
来自「JAVA学习初级变成,课本代码 有关程序计算和代码换算」· Java 代码 · 共 28 行
JAVA
28 行
//********************************************************************
// TempConverter.java Author: Lewis/Loftus
//
// Demonstrates the use of primitive data types and arithmetic
// expressions.
//********************************************************************
public class TempConverter
{
//-----------------------------------------------------------------
// Computes the Fahrenheit equivalent of a specific Celsius
// value using the formula F = (9/5)C + 32.
//-----------------------------------------------------------------
public static void main (String[] args)
{
final int BASE = 32;
final double CONVERSION_FACTOR = 9.0 / 5.0;
double fahrenheitTemp;
int celsiusTemp = 24; // value to convert
fahrenheitTemp = celsiusTemp * CONVERSION_FACTOR + BASE;
System.out.println ("Celsius Temperature: " + celsiusTemp);
System.out.println ("Fahrenheit Equivalent: " + fahrenheitTemp);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?