2个回答
推荐于2016-03-10 · 知道合伙人软件行家
关注
展开全部
public class Test {
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static String getString(){
try {
return br.readLine();
} catch (IOException e) {
return "";
}
}
public static int getInt(){
return Integer.parseInt(getString());
}
public static float getFloat(){
return Float.parseFloat(getString());
}
public static void main(String[] args){
float[] s = new float[5];
for(int i=0; i<s.length; i++){
System.out.print("请输入第 " + (i+1) + " 个数: ");
s[i] = getFloat();
}
float sum = 0;
for(int i=0; i<s.length; i++){
sum += s[i];
}
System.out.println("平均数: " + (sum/s.length));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询