I have a school project and what is needed is to 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 problem is i cannot get the min to work right. Right now just using 3 array indexes when this gets working then i will use the 10.
Thanks for the Help.
package assign6_sb;
import java.util.*;
public class Assign6_SB {
public static void main(String[] args) {
Scanner SC = new Scanner(System.in);
int[] midterm1 = new int[2];
int[] midterm2 = new int[2];
int[] fExam = new int[2];
int[] total = new int[2];
int m1Collect;
int m2Collect;
int fexCollect;
int max = total[0];
int min = total [0];
int counter1 = 0;
int counter2 = 0;
int counter3 = 0;
//fill midterm1
for(int index = 0; index < midterm1.length; index++)
{
counter1++;
System.out.println("Enter the grades for midterm 1: Student: "+counter1);
m1Collect = SC.nextInt();
midterm1[index] = m1Collect;
}
//fill midterm2
for(int index = 0; index < midterm2.length; index++)
{
counter2++;
System.out.println("Enter the grades for midterm 2: Student: "+counter2);
m2Collect = SC.nextInt();
midterm2[index]=m2Collect;
}
//fill fExam
for(int index = 0; index < fExam.length; index++)
{
counter3++;
System.out.println("Enter the grades for the final exam: Student: "+counter3);
fexCollect = SC.nextInt();
fExam[index]=fexCollect;
}
for (int index = 0; index < total.length; index++)
{
total[index] = (midterm1[index] + midterm2[index] + fExam[index]);
}
for (int index = 0; index < total.length; index++)
{
if(total[index] > max)
max = total[index];
}
for (int index = 0; index < total.length; index++)
{
if(total[index] < min)
min = total[index];
}
System.out.println("This is the Max " + max);
System.out.println("This is the Min " + min);
}
}