Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a JAVA program to calculate students average test scores and their grades.

ID: 3583891 • Letter: W

Question

Write a JAVA program to calculate students average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three arrays: a one-dimensional array to store the student names, a (parallel) twodimensional array to store the test score, and a parallel one-dimensional array to store grades.

Your program must contain at least the following methods: a method to read and store data into two arrays, a method to calculate the average test score and grade and a method to output the results. Have your program also output the class average. Grade calculation to be computed as follows: Marks Grade 85-100 A 75-84 B 65-74 C 50-64 D <50 F

Explanation / Answer

//import pacakage for reading input

import java.util.*;

import java.util.Scanner;

public class TestScore {

// one-dimensional array to store the student stdname using string array

String[] stdname = {"Johnson", "Aniston", "Cooper", "Gupta", "Blair", "Clark", "Kennedy", "Bronson", "Sunny", "Smith"};

// parallel two dimensional array to store the test score using int array

int[][] score = { {85, 83, 77, 91, 76}, {80, 90, 95, 93, 48}, {78, 81, 11, 90, 73}, {92, 83, 30, 69, 87}, {23, 45, 96, 38, 59}, {60, 85, 45, 39, 67}, {77, 31, 52, 74, 83}, {93, 94, 89, 77, 97}, {79, 85, 28, 93, 82}, {85, 72, 49, 75, 63} };

// parallel one-dimensional array to store grades using char array

char[] grades = new char[10];

// class average variable

double avg;

public static void main(String[] args)

{

//creating object of class for using methods

TestScore s = new TestScore();

s.readData();

s.calculateAVG();

s.printGrades();

}

//Reads and stores data into two arrays

public void readData()

{

Scanner sc = new Scanner(System.in);

for (int i = 0; i < stdname.length; i++)

{

System.out.print(" Name #" + (i + 1) + ": ");

stdname[i] = sc.nextLine();

for (int j = 0; j < Score[0].length; j++)

{

System.out.print("score #" + (j + 1) + ": ");

Score[i][j] = sc.nextInt();

}

sc.nextLine();

}

sc.close();

}

//calculates the average test score and grade

public void calculateAVG()

{

double avg = 0;

for (int i = 0; i < score.length; i++)

{

avg = 0;

for (int j = 0; j < score[0].length; j++)

{

avg = avg+score[i][j];

}

avg = avg/score[0].length;

if (avg >= 0 && avg < 20)

grades[i] = 'E';

elseif (avg >= 20 && avg < 40)

grades[i] = 'D';

elseif (avg >= 40 && avg < 60)

grades[i] = 'C';

elseif (avg >= 60 && avg < 80)

grades[i] = 'B';

elseif (avg >= 80 && avg <= 100)

grades[i] = 'A';

else

grades[i] = '?';

avg +=avg;

}

avg = avg/score.length;

}

//method for printing grads

public void printGrades()

{

System.out.println("Grades:");

for (int i = 0; i < grades.length; i++)

{

System.out.println(stdname[i] + ": " + grades[i]);

}

System.out.println("Class average: " + avg);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote