import java.util.*;
public class Revision {
static int[] num = new int[3];
static int i ;
static int sum;
public static void main(String arg[]) {
System.out.print("Enter the 4 numbers");
Scanner sc=new Scanner(System.in);
sum=sc.nextInt();
for(i=0; i<num.length; i++) {
sum=sum + num[i];
}
}
System.out.print("Sum=" + sum);
}
答案 0 :(得分:0)
这是你在找什么?
import java.util.*;
public class Revision {
static int NO_LIMIT = 4;
static int[] num = new int[NO_LIMIT];
static int i ;
static int sum;
public static void main(String arg[]) {
Scanner sc=new Scanner(System.in);
int count = 0;
while(count < NO_LIMIT){
System.out.print("Enter the number" + (count+1) +":");
num[count] = sc.nextInt();
count ++;
}
for(i=0; i<num.length; i++) {
sum=sum + num[i];
}
System.out.print("Sum=" + sum);
}
}