temperature.java

来自「Java 入门书的源码」· Java 代码 · 共 25 行

JAVA
25
字号
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.

/*  Uses method from the Io class provided
 *  with the text, to convert degrees Celsius
 *  to degrees Fahrenheit
 */

import iopack.Io;
public class Temperature {
   public static void main(String [ ] args) {
       double  hotC, coldC;
       double  hotF, coldF;
       hotC = Io.readDouble("Enter a hot temperature in Celsius");
       hotF = 9.0*hotC/5.0 + 32.0;
       System.out.print("The Fahrenheit temperature is: ");
       Io.println(hotF, 1);
       coldC = Io.readDouble("Enter a cold temperature in Celsius");
       coldF = 9.0*coldC/5.0 + 32.0;
       System.out.print("The Fahrenheit temperature is: ");
       Io.println(coldF,1);
       Io.readString("Press any key to exit");   // Added for IDE use
   }
}

⌨️ 快捷键说明

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