checkitems.java

来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 25 行

JAVA
25
字号
import javax.swing.*;
public class CheckItems
{
  public static void main(String[] args)
  {
    final int CONVERTS = 4;  // number of conversions to be made
    String s1;
    int count;           
    double fahren;
    for(count = 1; count <= CONVERTS; count++)
    {
      s1 = JOptionPane.showInputDialog("Enter a Fahrenheit temperature:");
      fahren = Double.parseDouble(s1);
      JOptionPane.showMessageDialog(null, 
            "The Celsius equivalent is " + convertTemp(fahren),
            "Program 6.4", JOptionPane.INFORMATION_MESSAGE);   
    }
    System.exit(0);
  }
   // convert fahrenheit to celsius
  public static double convertTemp(double inTemp)
  {
    return 5.0/9.0 * (inTemp - 32.0);
  }
}

⌨️ 快捷键说明

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