completethecall.java

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

JAVA
30
字号
import javax.swing.*;
public class CompleteTheCall
{
  public static void main(String[] args)
  {
    String s1;
    
    double firstnum, secnum;
    s1 = JOptionPane.showInputDialog("Enter a number:");
    firstnum = Double.parseDouble(s1);
    s1 = JOptionPane.showInputDialog("Great! Please enter a second number:");
    secnum = Double.parseDouble(s1);
    findMaximum(firstnum, secnum); // the method is called here
    System.exit(0);
  }  // end of main() method
   // following is the findMaximum() method
  public static void findMaximum(double x, double y)
  {                  // start of method body
    double maxnum;      // variable declaration
    if (x >= y)      // find the maximum number
      maxnum = x;
    else
      maxnum = y;
    JOptionPane.showMessageDialog(null, 
            "The maximum of " + x + " and " + y + " is " + maxnum, 
            "Maximum Value", JOptionPane.INFORMATION_MESSAGE);
                                             
  }  // end of method body and end of method
}  // end of class         

⌨️ 快捷键说明

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