I am having a problem completing my program. I am sure it is a simple mistake.
My results look something like this
How many students do you have?
2
How many Exam grades do you have?
4
Enter a score for student number: 1
98
Enter a score for student number: 1
78
Enter a score for student number: 1
88
Enter a score for student number: 1
83
Enter a score for student number: 1
77
Enter a score for student number: 1
77
Enter a score for student number: 1
77
Enter a score for student number: 1
import java.util.Scanner;
public class GradesAverage {
private static Scanner testScan;
//Program is not distinguishing between the students so when I run the program it never stops asking for the grades for student 1
public static void main(String[] args) {
int studTotal = 0;
int numScores = 0;
int lowest = 0;
int students = 0;
double studNormAve = 0;
testScan = new Scanner(System.in);
System.out.println("How many students do you have?");
students = testScan.nextInt();
System.out.println("How many Exam grades do you have?");
numScores = testScan.nextInt();
int[] studentsArray = new int[students];
int[] scoresArray = new int[numScores];
for(int bigTemp: studentsArray){ //determines how many scores are entered for each student
for(int temp: scoresArray) //determines the total and average scores for each student
{
int n = bigTemp+1;
System.out.println("Enter a score for student number: "+n);
temp = testScan.nextInt();
studTotal += temp;
if(temp<lowest)
{
lowest = temp;
}
}
}
studNormAve = (double)(studTotal/numScores);
System.out.println("Here is the student's average test scores.");
System.out.println(studNormAve);
{
if ((studNormAve>= 90) && (studNormAve <= 100)){
System.out.println("The student's grade is A. ");}
else if ((studNormAve >= 80) && (studNormAve < 90)){
System.out.println("The letter grade is B");}
else if ((studNormAve >= 70) && (studNormAve < 80)){
System.out.println("The letter grade is C");}
else if ((studNormAve >= 60) && (studNormAve < 70)){
System.out.println("The letter grade is D");}
else if ((studNormAve >= 0) && (studNormAve < 60)){
System.out.println("The letter grade is F");}
}
}
}