-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDropLowestGrade.java
More file actions
56 lines (54 loc) · 1.83 KB
/
DropLowestGrade.java
File metadata and controls
56 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.Scanner;
class DropLowestGrade
{
public static void main(String[] args)
{
final int ARRAYSIZE = 5;
double average;
String[] studentNames = {"Ann", "Bob", "Cara", "Don", "Eve"};
int[][] studentGrades = new int[ARRAYSIZE][ARRAYSIZE];
final int[] NEW_STUDENT_GRADES = new int[ARRAYSIZE];
for (int row = 0; row < studentGrades.length; row++)
{
System.out.println("Please enter test Scores (0 - 100) for " + studentNames[row]);
for (int column = 0; column < studentGrades[row].length; column++ )
{
getstudentTestScores(studentGrades, row, column);
}
average = calculateAverageGrade(studentGrades, row);
//findLowestGrade()
//removeLowestGrade()
//assignLetterGrade ();
displayStudentGradeReport(average);
}
}
public static void getstudentTestScores(int[][] testScores, int r, int c)
{
final int MAXSCORE = 100;
final int MINSCORE = 0;
Scanner input = new Scanner(System.in);
System.out.print("Test # " + ++c + ": ");
testScores[r][c-1] = input.nextInt();
while (testScores[r][c-1] < MINSCORE || testScores[r][c-1] > MAXSCORE)
{
System.out.print("Error. You must enter a score in the range 0-100: ");
testScores[r][c-1] = input.nextInt();
}
}
public static double calculateAverageGrade(int[][] testScores, int r)
{
double avg = 0;
double sum = 0;
int scoresAmount = 5;
for (int i = 0; i < testScores.length; i++)
{
sum += testScores[r][i];
}
avg = sum / scoresAmount;
return avg;
}
public static void displayStudentGradeReport(double avg)
{
System.out.println("The average: " + avg);
}
}