OOD Project: gpa calculator

Classwork:
Write a program, YI_GPACalculator.java to read grades from a text file. The grades will have a specific structure so the marking periods, the subjects, and categories can be identified.

The file structure given here is just an example. You should notice it has some redundancy. You can configure your own structure to enable easier implementation.

[spoiler title=’gpadata.txt’]
Q1
Subject: English
Categories start:
Homework: .30
Classwork: .30
Test: .40
Categories end
Data:
Homework:
75
90
85
Classwork:
65
75
78
Test:
100
98
99
Subject: Math
Categories start:
Homework: .25
Classwork: .25
Test: .50
Categories end
Data:
Homework:
86
88
100
Classwork:
60
70
80
Test:
100
90
91
Q1 end
Q2
Subject: English
Categories start:
Homework: .30
Classwork: .30
Test: .40
Categories end
Data:
Homework:
95
80
81
Classwork:
55
95
88
Test:
93
100
85
Subject: Math
Categories start:
Homework: .25
Classwork: .25
Test: .50
Categories end:
Homework:
86
88
100
Classwork:
60
70
80
Test:
87
96
81
Q2 end
[/spoiler]

Here is some code that might help you read the file.

  1. Using PU libraries: StdIn.java
/**
 * Calculate the GPA given a file with all the requirements.
 * Q1
 * Subject: English
 * Categories start:
 * Homework: .30
 * Classwork:
 * ....
 * ....
 * END
 * 
 * java GPACalculator1 < gpadata.txt
 * 
 */
public class GPACalculator1
{
    public static void main(String [] args)
    {

            while (StdIn.hasNextLine()) {
                String s1 = StdIn.readLine();
                System.out.println(s1);
            }
          
    
    }
    
}

  1. Using java libraries:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
/**
 * Calculate the GPA given a file with all the requirements.
 * Subject: English
 * Catgories beginning:
 * 
 */
public class GPACalculator2
{
    public static void main(String [] args)
    {
        
        File file = new File(args[0]);
    
        try {
    
            Scanner sc = new Scanner(file);
    
            while (sc.hasNextLine()) {
                String s1 = sc.nextLine();
                System.out.println(s1);
            }
            sc.close();
        } 
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    
    }
    
}

Before you get started writing code,
1. Draft a flowchart or a concise pseudocode.
2. Trace few grades from one subject for Q1 and Q2.
3. Manually calculate the GPA for the data used in the trace.
4. Confirm that your trace and calculation coincide.

Submit all your work to edmodo.com.