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

📄 accumulateelements.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import javax.swing.*;
public class AccumulateElements
{
  public static void main(String[] args)
  {
    final int NUMELS= 5;
    String s1;
    int i;
    int total = 0;
      // declare and allocate the array
    int grade[] = new int[NUMELS]; // allocate the array
 
    for (i = 0; i < NUMELS; i++)    // Enter the grades
    {
      s1 = JOptionPane.showInputDialog("Enter a grade: ");
      grade[i] = Integer.parseInt(s1);
    }
    System.out.print("The total of the grades");
    for (i = 0; i < NUMELS; i++)     // Display and total the grades
    {
       System.out.print("  " + grade[i]);
       total =  total + grade[i];
    }
    System.out.print(" is " + total);
    System.exit(0);
  }
}

⌨️ 快捷键说明

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