📄 averagefivenumbers.java
字号:
import javax.swing.*;
public class AverageFiveNumbers
{
// This method calculates the average
// of 5 user-entered numbers
public static void main(String[] args)
{
final int MAXNUMS = 5;
int count;
double num, total, average;
String s1;
total = 0.0;
for (count = 0; count < MAXNUMS; count++)
{
s1 =JOptionPane.showInputDialog("Enter a number:");
num = Double.parseDouble(s1);
total = total + num;
}
average = total / MAXNUMS;
JOptionPane.showMessageDialog(null,
"The average of the data entered is " + average,
"Program 5.11",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -