For Java: Grading Schema: In a separate function, you will implement a grading schema. Write a program that reads a students name together with his
For Java:
Grading Schema: In a separate function, you will implement a grading schema. Write a program that reads a students name together with his or her test score from a file given by the user. The first two values in the file will represent the number of students followed by the number of tests. The program should then compute the average test score for each student and assign the appropriate grade (A, B, C, D, E or F) as well as the average of each test. Your program must perform the following functions. a) A void function calculateAverage, to determine the average of the test scores for each student. b) A value-returning function, calculateGrade, to determine and return each students grade letter. c) A void function calculateTestAvg that calculates the average of all tests and overall average of students. d) A void function printGrades that prints the grades values, average marks and grade letter followed by the average of all tests and students.
Output:
This is what I have so far:
package readwritetofile;
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; /** * * @author Jarvis */ public class Grades {
private static final String FILENAME2 = "/Users/Jarvis/Documents/Students.txt"; public static void main(String[] args) { BufferedReader br = null; FileReader fr = null; String students [] = new String[10]; int [][] grades = new int [10][5]; String[] words; String sCurrentLine; int counter=0; int [] tests = new int [10]; System.out.printf("Students\tTest1\tTest2\tTest3\tTest4\ttest5\tAverage ");
try {
fr = new FileReader(FILENAME2); br = new BufferedReader(fr);
br = new BufferedReader(new FileReader(FILENAME2)); while ((sCurrentLine = br.readLine()) != null) { words = sCurrentLine.split(" "); students[counter]=words[0]; System.out.printf(students[0]+ " ");
for (int i=1; i
} //end of outer for loop
} // end of while loop } catch (IOException e) {
e.printStackTrace();
} // end of catch counter++; }//end of main public static void calculateAverage (int [] grades){ ArrayList sum += grades[i]; // Divides the sum of the numbers by the number of grades averageGrades.add((sum/(double)grades.length)); } // end of inner for loop for(int j = 0; j =0 && grade = 60 && grade =70 && grade =80 && grade =90 && grade } // end of calculateGrade method public static void calculateTestAverage (int students [][]){ int sumTotal = 0; for (int i=0; i } // end of method printGrades } // end of grades
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started