convtemp.txt

来自「java的一经典教程」· 文本 代码 · 共 25 行

TXT
25
字号
// Computes the Fahrenheit equivalent of 20 Celsius
import javax.swing.JOptionPane;

public class ConvTemp
{
	public static void main(String[] args)
	{
		// ratio of F degree to C degree
      final double FACTOR = 9.0 / 5.0;
		final double SHIFT = 32;  // 0 C = 32 F

		double cel = 20;  // temp for conversion
		double fah;  // Fahrenheit equivalent

      // do the calculation
		fah = cel * FACTOR + SHIFT;

      // output the answer
		JOptionPane.showMessageDialog(null,
		   "The Fahrenheit equivalent of 20 Celsius is "
			+ fah + " F");

      System.exit(0);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?