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){
int[] s = new int[5];
for(int i=0; i<s.length; i++){
System.out.print("请输入第 " + (i+1) + " 个数: ");
s[i] = getInt();
}
float sum = 0;
for(int i=0; i<s.length; i++){
sum += s[i];
}
System.out.println("和: " + sum);
}
}
温馨提示:内容为网友见解,仅供参考