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

Write a program using JAVA that processes the file Grades.dat and produces a rep

ID: 3757701 • Letter: W

Question

Write a program using JAVA that processes the file Grades.dat and produces a report with the following headings:

Grades for CIS1100

Last Name       First Name       ID       Average
------------       -----------         ----     -----------
------------       -----------         ----     -----------
------------       -----------         ----     -----------
------------       -----------         ----     -----------
------------       -----------         ----     -----------
Class average:   --------------

The final grade calculated as follows: 30% tests; 30% final exam, 20% projects, 20% labs.


Grades.dat (lastName,firstName,id,test1,test2,test3,test4,project1,project2,project3,project4,finalExam,lab1,lab2,lab3,etc.) Note: number of labs is not the same for each student

Smith,Tim,1112,87,85,82,99,90,95,100,95,83,100,100,100,90,95
Thomas,Mary,1212,97,81,85,78,100,100,100,95,87,100,100,100,100,100
Herbert,Bob,1214,78,82,84,87,75,90,100,100,78,80,70,90,80,80,90,90,100,100
Adams,Terry,1125,68,88,87,92,100,80,90,100,90,90,80,85,75,80,70,100
Jenkins,Macy,1356,88,95,94,95,80,80,80,80,96,100,100,100,100,100,100,100,100
Locks,Mike,1432,78,88,89,91,90,80,90,80,75,90,90,90,90,100,100,100,95,95,95
Wilson,Bill,1142,87,85,83,93,80,90,100,90,89,85,100,100,100,90,95

Explanation / Answer

Please find the required solution:

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class GradesCalculator {
   public static void main(String[] args) throws FileNotFoundException {
       Scanner input = new Scanner(new File("Grades.dat"));
       while (input.hasNext()) {
           String line = input.nextLine();
           String[] parsed = line.split(",");
           int finalSum = 0;
           System.out.print(parsed[0] + " " + parsed[1] + " " + parsed[2]
                   + " ");
           int testSum = Integer.parseInt(parsed[3])
                   + Integer.parseInt(parsed[4]) + Integer.parseInt(parsed[5])
                   + Integer.parseInt(parsed[6]);
           int testAvg = testSum / 4;
           finalSum = (int) (testAvg * 0.3);
           int projSum = Integer.parseInt(parsed[7])
                   + Integer.parseInt(parsed[8]) + Integer.parseInt(parsed[9])
                   + Integer.parseInt(parsed[10]);
           int projAvg = projSum / 4;
           finalSum += (int) (projAvg * 0.2);
           finalSum += (int) (Integer.parseInt(parsed[11]) * 0.3);
           int labSum = 0;
           int i = 12;
           while (i < parsed.length) {
               labSum += Integer.parseInt(parsed[i]);
               i++;
           }
           finalSum += (int) (labSum/(parsed.length-12) * 0.2);
           System.out.println(finalSum);
       }
       input.close();
   }
}

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