sampleinputdialog.java

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

JAVA
22
字号
import javax.swing.*;
public class SampleInputDialog
{
  public static void main (String[] args) 
  {
     String s1, s2;
     double num1, num2, average;
     s1 = JOptionPane.showInputDialog("Enter a number:");
     s2 = JOptionPane.showInputDialog("Great! Now enter another number:");
    
     num1 = Double.parseDouble(s1);
     num2 = Double.parseDouble(s2);
     average = (num1 + num2)/2.0;
   
     JOptionPane.showMessageDialog(null, 
             "The average of " + num1 + " and " + num2 + " is " + average,
               "Program 3.13",
             JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
 }
}

⌨️ 快捷键说明

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