?? average.java
字號:
import javax.swing.JOptionPane;//求平均數(shù)
public class Average
{
public static void main(String args[])
{
int total,counter,inputValue,average;
String input;//初始化變量
total=0;
counter=1;//循環(huán)結(jié)構(gòu),循環(huán)十次
while(counter<=10)
{input=JOptionPane.showInputDialog("請輸入數(shù)據(jù):");//輸入數(shù)據(jù)
inputValue=Integer.parseInt(input);
total=total+inputValue;//求總和
counter+=1;
}
average=total/10;//求平均數(shù)
JOptionPane.showMessageDialog(null,"平均數(shù)是:"+average,"平均數(shù)是:",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -