Basically Im trying to make a program that allows a teacher to input grades for a test for each student then after they've inputted the grades it gives the teacher a sum of all the grades they inputted
public static void grades(){
List<Integer> grade = new ArrayList<Integer>();
int gradetotal = IntStream.of(grades).sum;/* sum */
int gradelistnumber = 1;
int inputedgrade = 0;
while(inputedgrade != -1){
System.out.println("Enter Grade for student " + gradelistnumber + " (1-50): ");
inputedgrade = sc.nextInt();
grade.add(inputedgrade);
gradelistnumber++;
}
System.out.println("Class Average: " + gradetotal / 50 * 100);
}
I'm trying to figure out how to get the sum of the array list grades .
See Question&Answers more detail:os