⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findthemaximum.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import javax.swing.*;
public class FindTheMaximum
{
  public static void main(String[] args)
  {
    String s1, outMessage;
    
    double firstnum, secnum, max;
    s1 = JOptionPane.showInputDialog("Enter a number:");
    firstnum = Double.parseDouble(s1);
    s1 = JOptionPane.showInputDialog("Great! Please enter a second number:");
    secnum = Double.parseDouble(s1);
    max = findMaximum(firstnum, secnum); // the method is called here
    JOptionPane.showMessageDialog(null, 
            "The maximum of the two numbers is " + max, 
            "Maximum Value", JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
  }
    // following is the method findMaximum()
  public static double 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;
    
    return maxnum;                                          
  }  // end of method body and end of method
}

⌨️ 快捷键说明

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