Grade Point Averages

Due 11:59:59AM January 14th

Problem

For every student the university stores a wealth of information. Much of this data pertains to the student’s grade point average, (GPA). A GPA is computed by dividing the quality credits achieved by the credit hours attempted. Quality credits are earned for passing grades in courses. The quality credits earned in a course are obtained by multiplying the corresponding letter grade quality credits by the credit hours for the course. (See the table below for the letter grade quality credits.)

Quality Points
A- B+ B- C+ C- D+ D-
4.0 3.7 3.3 3.0 2.7 2.3 2.0 1.7 1.3 1.0 0.7 0.0

 

A student has several GPAs: overall GPA, term GPA and major GPA. The overall GPA is the total quality credits achieved in all courses divided by the total credit hours attempted. A term or semester GPA is simply the quality credits earned during a particular term divided by the credit hours attempted during the term. A student’s major GPA is the sum of all the quality credits earned for courses taken in a student’s department divided by the total major departmental hours attempted. (Note: some schools and departments define major GPA differently. Courses passed with a grade of ’P’ do not affect a GPA, i.e. the hours are not counted in the hours attempted. )

The program you create for this assignment will compute students’ overall GPAs and major GPAs for all the courses each student has attempted plus statistics and produce bar chart GPA output..

Sample Input / Output Files

Downloading Sample Input/Output Files

To download a file, right-click on the link. Select "Save Target As..." or "Save Link As...", choose your BlueJ project directory, and save it.

Reading Student Files

Student Data
Student Data Field Name Field Contents
idNumber character string
name character string
address character string
state character string
zip positive integer
major character string
minor character string
rank positive integer
gpa real value
altGPA real value
qualCred real value
hrsAtt real value
The program must be designed to allow it to easily work with any input filenames without requiring the code of the class to be changed. This implies that I/O filenames must not be "hard wired" into the solution class code without the possibility of being changed. To satisfy this requirement command line parameters should be utilized. The order of the command line file name parameters should be student filename, courses filename, output filename. It is certainly acceptable for testing purposes to "hard wire" I/O file names in the testing code. There are two input files for this program: a student data file and a corresponding courses data file.

The "students.txt" student data file will store the student information. The format of the student file will now be described. The first line of the student input file is a label line that must be ignored. The second line specifies twelve data fields, separated by one tab character. The order of the data fields on the line and the type of value in the field are given in the "Student Data" table at the right. The last three fields are the alternate (major) GPA, the overall quality credits earned and the overall hours attempted. Note that the contents of the last four fields may not be up-to-date, (i.e. they should be assumed to be incorrect). Following the second line will be other lines of data for other students.
Sample input/output files are linked above. A sample student.txt input file is shown below:

// ID    	Name		Address			St	Zip  	Majr	Minr	Rk	QCA   	AltQCA	Crd	Hrs
135792468	Wayne,John Duke	101 Hollywood Way	CA	40815	CS	MATH	10	3.2667	4.0000	49	15
436587901	Mix, Tom	828 Dallas Ave	TX	52848	CS	MATH	20	3.1245	3.0000	54.0000	30.00
147036925	Brennan, Walter	939 Brownsville Ave	TX	71392	CS	MATH	30	3.2831	2.5200	54	30


Note that due to web browser window width limitations, (not file line size), the lines of the input file may wrap onto multiple lines.

 

Courses Data
Courses Data Field Name Field Contents
idNumber character string
index positive integer
department character string
courseNum positive integer
term character string
year positive integer
creditHours decimal place
grade character string
The contents of the courses data file "courses.txt" file will now be explained. The first line is a label line that must be skipped. Each course record, starting on line 2 of the courses file, specifies 9 data fields, separated by one tab character. The order of the data fields on a line and the type of value in the field are given in the "Courses Data" table at the right. The term field abbreviations are as follows: FS - fall semester, SS - Spring Semester, U1 - first summer term, and U2 - second summer term. The grade field codes are given above in the letter grade quality credits table. Note: a generic Vector or generic ArrayList must be used to store all of the student record data.

It may NOT be assumed that the ID number in a course record will match one of the ID numbers in the students file. All course records that do not match a student’s ID must be ignored. No ordering of the course records in the file may be assumed.

A sample coursess.txt input file is shown below:
// ID    	Indx  Dept	Crse	Tm	Year	Cred	Grd	Title
135792468	9345	CS	1044	FS	1999	3.00	A	Intro Prog in C
135792468	5231	CS	1205	FS	1999	1.00	A	Oper Sys Tools I
135792468	1350	CS	1206	SS	2000	2.00	B+	Oper Sys Tools II
135792468	9268	CS	1104	FS	1999	3.00	A	Intro to CS
135792468	1365	CS	1704	SS	2000	3.00	B	Intro Data Struct/SE
135792468	6075	ENGL	1105	FS	1999	3.00	C	Fresh English
135792468	2080	ENGL	1106	SS	2000	3.00	B+	Fresh English
135792468	7410	MATH	1114	FS	1999	2.00	C+	Elem Lin Alg
135792468	7430	MATH	1205	FS	1999	3.00	B+	Calculus
135792468	3470	MATH	1206	SS	2000	3.00	B	Calculus
135792468	3510	MATH	1224	SS	2000	2.00	B-	Vector Geometry
135792468	8082	PHYS	2074	SS	2000	3.00	A-	Hilights of Physics
436587901	0282	COMM	2054	U2	2001	3.00	C	Intrp Film
436587901	9345	CS	1044	FS	1999	3.00	B+	Intro Prog in C
436587901	5231	CS	1205	FS	1999	1.00	B-	Oper Sys Tools I
436587901	1350	CS	1206	SS	2000	2.00	P	Oper Sys Tools II
436587901	9268	CS	1104	FS	1999	3.00	B+	Intro to CS
436587901	1365	CS	1704	SS	2000	3.00	B	Intro Data Struct/SE
436587901	9267	CS	2704	FS	2000	3.00	C+	Obj Orient Prog
436587901	9260	CS	2504	FS	2000	3.00	F	Intro Comp Org
436587901	2261	CS	2604	SS	2001	3.00	B	Data Structures
436587901	6075	ENGL	1105	FS	1999	3.00	A	Fresh English
436587901	2080	ENGL	1106	SS	2000	3.00	C-	Fresh English
436587901	2181	ENGL	2344	SS	2001	3.00	A	Sci Fic & Fan
436587901	0246	ENT	2004	U2	2001	3.00	B	Insects Hum Soc
436587901	2184	HST	1504	SS	2001	3.00	F	Hum, Sci & Tech
436587901	7410	MATH	1114	FS	1999	2.00	C	Elem Lin Alg
436587901	7430	MATH	1205	FS	1999	3.00	A-	Calculus
436587901	3470	MATH	1206	SS	2000	3.00	C+	Calculus
436587901	3510	MATH	1224	SS	2000	2.00	D	Vector Geometry
436587901	7264	MATH	2224	FS	2000	3.00	C-	Mult Var Calc
436587901	9276	MATH	2534	FS	2000	3.00	A	Discrete Math
436587901	4471	MATH	2214	SS	2001	3.00	C-	Diff Eqns
436587901	8082	PHYS	2074	SS	2000	3.00	D	Hilights of Physics
436587901	8140	PHYS	2305	FS	2000	4.00	C	Found Phys I
436587901	7142	PHYS	2306	SS	2001	4.00	A	Found Phys I
436587901	0138	PSYC	2004	U1	2001	3.00	B-	Intro Psych
436587901	0126	SOC	1004	U1	2001	3.00	C-	Intro Soc
147036925	3429	CHEM	1035	FS	2001	3.00	A-	General Chemistry
147036925	3432	CHEM	1045	FS	2001	3.00	C	General Chemistry La
147036925	0282	COMM	2054	U2	2001	3.00	B-	Intro Film
147036925	9345	CS	1044	FS	1999	3.00	A	Intro Prog in C
147036925	5231	CS	1205	FS	1999	1.00	C+	Oper Sys Tools I
147036925	1350	CS	1206	SS	2000	2.00	B+	Oper Sys Tools II
147036925	9268	CS	1104	FS	1999	3.00	A-	Intro to CS
147036925	1365	CS	1704	SS	2000	3.00	C+	Intro Data Struct/SE
147036925	9267	CS	2704	FS	2000	3.00	C+	Obj Orient Prog
147036925	9260	CS	2504	FS	2000	3.00	B	Intro Comp Org
147036925	2261	CS	2604	SS	2001	3.00	C	Data Structures
147036925	6420	CS	3204	FS	2001	3.00	C+	Oper Sys
147036925	6532	CS	3414	FS	2001	3.00	A	Numerical Methods
147036925	6536	CS	3604	FS	2001	3.00	B-	Prof Computing
147036925	6075	ENGL	1105	FS	1999	3.00	B-	Fresh English
147036925	2080	ENGL	1106	SS	2000	3.00	B-	Fresh English
147036925	2181	ENGL	2344	SS	2001	3.00	A	Sci Fic & Fan
147036925	0246	ENT	2004	U2	2001	3.00	P	Insects Hum Soc
147036925	2184	HST	1504	SS	2001	3.00	C	Hum, Sci & Tech
147036925	7410	MATH	1114	FS	1999	2.00	A	Elem Lin Alg
147036925	7430	MATH	1205	FS	1999	3.00	P	Calculus
147036925	3470	MATH	1206	SS	2000	3.00	C+	Calculus
147036925	3510	MATH	1224	SS	2000	2.00	B-	Vector Geometry
147036925	7264	MATH	2224	FS	2000	3.00	C-	Mult Var Calc
147036925	9276	MATH	2534	FS	2000	3.00	P	Discrete Math
147036925	4471	MATH	2214	SS	2001	3.00	C-	Diff Eqns
147036925	6471	MATH	3134	FS	2001	3.00	B-	App Comb & Graph The
147036925	8082	PHYS	2074	SS	2000	3.00	A	Hilights of Physics
147036925	8140	PHYS	2305	FS	2000	4.00	D+	Found Phys I
147036925	7142	PHYS	2306	SS	2001	4.00	B+	Found Phys I
147036925	0138	PSYC	2004	U1	2001	3.00	C+	Intro Psych
147036925	0126	SOC	1004	U1	2001	3.00	B	Intro Soc


It may also NOT be assumed that the course records in the file will be in any particular order. You may assume that the student and course data is valid and does not need to be checked for errors. Your program must be written so that it will detect when it’s out of input and terminate correctly.

Writing the Student Report File

The first line of your output must display the column labels shown below. The second and following lines will contain student data, ordered by name, aligned under the appropriate headers, echoed from the input file, and showing the results of the GPA calculations. Note that the GPA calculations must be based upon all of the course file records. The line following the GPA computations must be blank.

The next section of the output, will give a horizontal bar chart of each student’s GPA in corresponding order by name, but labeled by their ID. The beginning of the chart must have the columns labels exactly as shown. The number of following lines of the output file, (the GPA bar chart lines), will depend upon the number of student input records. Each line, one per student, will contain the ID aligned under the label, immediately followed by a colon. Beginning in column eleven on each line will be a number of asterisks representing the GPA bar chart value for that term. Forty columns will be used for the bar chart line representation of each GPA. To determine how many asterisks for a GPA should be output, a mapping of the numerical GPA value to the maximum column length must be performed. The equation for this mapping is: (GPA/MaxGPA) * MaxColumnLength, for this particular bar chart the formula becomes: (GPA/4.0) * 40. The mapping should be rounded to the nearest integer value for an exact number of asterisks to be output.

 

An instructor needs to determine certain statistics upon all of the students' GPAs. Along with a mean, (average of the GPAs, represented by the Greek letter μ), another important statistic that needs to be computed is the standard deviation, (represented by the Greek letter σ). The standard deviation is a measure of dispersal of values in a population about the mean. (A value in this case is a student's GPA and the population is the data set of all of the students' GPAs.) For another example, IQ scores typically have a mean of 100 and a standard deviation of 15. If one were to chart IQ scores for a group of normal student the graph at the right would most likely be produced.


The most important result in the field of statistics, the Central Limit Theorem, explains why most populations tend to fall into this type of distribution, called a normal distribution and how population values are dispersed. Instructors tend to use the standard deviation to determine letter grades , among other things. One of the formulas that can be used to compute the standard deviation for a population of student GPAs is:


Following the output of the student GPA bar chart, your program must also output the mean (μ) and the standard deviation (σ) for the student GPAs.

Your program must, by default, write output data to a file named gpa.txt The sample output file shown below corresponds to the input data given above:

ID Number Name               Major Minor Rank GPA    AltGPA QCredits Hours Att.
147036925 Brennan, Walter      CS  MATH  30   2.7631 2.9267 232.1000 84.00
436587901 Mix, Tom             CS  MATH  20   2.4370 2.4947 177.9000 73.00
135792468 Wayne,John Duke      CS  MATH  10   3.2097 3.6333 99.5000  31.00

Student GPAs:
ID Number ........1.0.......2.0.......3.0.......4.0
147036925:****************************
436587901:************************
135792468:********************************

Average GPA:        2.8033
Standard Deviation: 0.3167


You are NOT required to use this exact horizontal spacing. Your output must satisfy the output requirements of the previous program as they logically apply. In addition, the output for this program must satisfy the following constraints:

Solution Requirements

Student Class

You must provide a class called Student to model a student and their grade information.

Course Class

You must also provide a class called Course to model a single course that a student has taken.

Advisees Class

You must also provide a class called Advisees to model a group of students.

BarChart Interface

You must also provide an interface called BarChart.

public interface BarChart
{
    public void setMaxColLength( int maxColumns );
    public void setMaxRangeValue( double maxRange );
    public int getMaxColLength( );
    public double getMaxRangeValue( );

    public int getBarLength( double value );
}

BarChartGPAs Class

You must also provide a class called BarChartGPAs that implements the BarChart interface. Your BarChartGPAs class must also provide a default constructor.

Note that none of the methods in the BarChart interface throws any exceptions. In particular, this means that none of the methods provided by your BarChartGPAs class can throw I/O exceptions.

The BarChart methods are fairly simple in behavior. Your BarChart should maintain an internal maximum column length for the chart, an internal maximum rangle limit for the provided output values. The setMax_() and getMax_() methods simply stores and return these internal class values. The getBarLength() method simply returns the number of columns to be output for a bar to represent the provided value.The setMaxColLength should default to a value of 80 for non-positive parameters. The setMaxRangeValue must protect getBarLength from division by zero. If setMaxRangeValue is invoked with a zero parameter, then a value of one should be stored instead. Note that only positive values for bar length columns make sense. Thus a negative value parameter only makes sense if the maximum range value is also negative. (Likewise, a positive value parameter only makes sense if the maximum range value is also positive.) Instead of returning a nonsense column length, the getBarLength() method must return the maximum int value: Integer.MAX_VALUE when a meaningless value would otherwise be returned.

In addition, your BarChartGPAs class must have a default constructor that takes no parameters.

Implementation Hints

You are encouraged to design your solution piecemeal, (i.e., stepwise implementation). Begin by coding tests for the Student and Course classes. After you have coded the tests then implement the methods for the classes one at a time testing and debugging them separately. Think about using a possible driver/organizing class to instantiate and execute the Student and Course classes. Then identify the major tasks that have to remain be done, and then add detail for each of those tasks. Apply a similar strategy to the GPA computation process for this program. Then continue by coding tests for the Advisees and BarChartGPAs classes. Followed by implementing the Advisees and BarChartGPAs classes. Remember that by decomposing the problem you allow yourself to focus on solving a single part of the problem at any one time. You will find that this will greatly increase your odds of producing a correct solution.

Testing Your GPA Calculator

When it comes to testing, remember to write one or more test cases for each method that your write in your solution. Preferably, you should write these tests before (or as) you write the method itself, rather than saving testing until your code works. As you work on larger and larger programs, it is important to build skills in convincing yourself that the parts you have already written work as you intend, even if the full solution has not been completed.

Also, in addition to trying to think of various cases that your methods should add formatting to, also write test cases for scenarios where a method should not take action (or should signal an error condition, if that is the behavior intended).

Finally, be sure to review the section on Testing I/O-based Operations in the Java stream I/O tutorial.

Submit Your Solution

On BlueJ’s main menu, click Tools->Submit.... Click on "Browse...", double-click to open the "CS 1114 Programs" folder, and select CBE. Click "OK". Click "Submit". Click on the link provided in the submission response in order to view the results of the automated phase of program grading.

If no "CBE" entry is visible on BlueJ’s submission menu, then the Web-CAT Grader is not yet accepting submissions for this assignment. Wait for a message posted to this CBE web site that submissions are being accepted, and try again.

If any errors, warnings or suggestions are indicated, you can fix them and resubmit. You are expected to fix all such issues in your code. You may resubmit as many times as you like, up until the deadline. Be careful as the due time approaches--no late submissions will be accepted.

copyright © 2019 Virginia Tech, ALL RIGHTS RESERVED
Last modified: Oct. 24, 2021, 11:09:08 am EDT, by Dwight Barnette <barnette@vt.edu>