exercise5_2.java

来自「Introduction to java programming 一书中所有编程」· Java 代码 · 共 35 行

JAVA
35
字号
import javax.swing.JOptionPane;public class Exercise5_2 {  public static void main(String[] args) {    // Prompt the user to enter the first number    String numberString = JOptionPane.showInputDialog(null,      "Enter an integer");    int max = Integer.parseInt(numberString);    int count = 1;    String inputNumbers = max + " ";    // Prompt the user to enter the remaining five numbers    for (int i = 1; i <= 5; i++) {      numberString = JOptionPane.showInputDialog(null,        "Enter an integer");      int temp = Integer.parseInt(numberString);      inputNumbers += temp + " ";      if (temp > max) {        max = temp;        count = 1;      }      else if (temp == max)        count++;    }    JOptionPane.showMessageDialog(null,      "The array is: " + inputNumbers + "\n" +      "max is " + max + "\n" +      "the occurrence count is " + count);    System.exit(0);  }}

⌨️ 快捷键说明

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