thank you for your help.
Here is the assignment:
Computer Technology Instructor has a small class of 10 students. The instructor evaluates the performance of students in the class by administering 2 midterm tests and a Final Exam. Write a program that prompts the instructor to enter the 10 grades of midterm 1 and store these numbers in an array. Next prompt for the 10 grades of midterm 2 and store these numbers in a different array. Next prompt for the 10 grades of the Final Exam and store these in a different array. Next add midterm1 to midterm2 to Final and store the totals in a different array. Next, scan the array that has the totals and identify the minimum grade and maximum grade. Inform the instructor of the minimum grade and maximum grade.
The two bold phrases are where I am having problems. Everything works except for the minimum grade and maximum grade. Here is what it tells me, after I've only entered numbers between 65 and 100:
The highest test score is: 276 The lowest test score is: 249
Here is my code:
import java.util.Scanner;
public class Arrays {
public static void main(String[] args) {
// Create a scanner
Scanner input = new Scanner(System.in);
// Prompt for the 1st mid term
int [] midTerm1 = new int[10];
int [] midTerm2 = new int[10];
int [] finalExam = new int[10];
int [] grades = new int[10];
for (int i = 0; i < midTerm1.length; i++){
System.out.println("Enter the 10 Mid Term 1 grades: ");
midTerm1[i] = input.nextInt();
}
// Prompt for the 2nd mid term
for (int i = 0; i < midTerm2.length; i++){
System.out.println("Enter the 10 Mid Term 2 grades: ");
midTerm2[i] = input.nextInt();
}
// Prompt for Final grades
for (int i = 0; i < finalExam.length; i++){
System.out.println("Please enter a Final Exam grade: ");
finalExam[i] = input.nextInt();
}
for (int i = 0; i < grades.length; i++){
grades[i] = (midTerm1[i] + midTerm2[i] + finalExam[i]);
}
int minGrade = grades[0];
int maxGrade = grades[0];
for (int i = 0; i < grades.length; i++)
{
if (minGrade > grades[i])
minGrade = grades[i];
if (maxGrade < grades[i])
maxGrade = grades[i];
}
System.out.print("The highest test score is: " + maxGrade);
System.out.print("The lowest test score is: " + minGrade);
}
}