CIS 1068 - Homework 5

Handed out: 02/16/10
Due: by 10pm on 02/22/10

You will write a Java class called Grades that must be saved into a file called Grades.java. You should email this file to your TA.

Your program will read in grades for a student in a fictional course, and it will calculate the overall course grade for the student. Below is one example log of execution of the program. The course grade is a weighted average of three components: a homework grade, an exam 1 grade, and an exam 2 grade. To compute a weighted average, the student's point scores for each component are divided by the total points available for that component and multiplied by that component's weight.

The homework score is determined by the student's scores on a series of assignments, as well as points for attending labs. Each lab is worth 4 points, up to a maximum of 20 possible lab points. The number of assignments is entered by the user, as are the student's scores for each assignment and the maximum number of points for each assignment, as shown in the execution log below.

In the log of execution shown, the course has 50% weight for homework, 20% weight for exam 1, and 30% weight for exam 2. There are 3 homework assignments worth 15, 20, and 25 points respectively. The student received homework scores of 14, 16, and 19, and attended 4 out of 5 labs (earning 16 points for doing so) missing one lab. The student received an exam 1 score of 81. The student earned an exam 2 score of 95; the exam was curved by +10 points, but exam scores are capped at 100, so the student was given 100 for exam 2.

The following calculations produce the student's course grade from the above data

grade  = weightedHomeworkScore + weightedExam1Score + weightedExam2Score
       = ((14 + 16 + 19 + (4 * 4))/(15 + 20 + 25 + 20)*50 + 81/100*20 + 100/100*3
       = 40.63 + 16.2 + 30.0
       = 86.83
Note that the preceding equations are not Java math. In Java, an integer expression such as 81/100 would evaluate to 0, but above the value intended is 0.81.

Here is a possible interaction with the program:

	This program accepts your homework and
	two exam scores as input and computes
	your grade in the course.

	Homework and Exam 1 weights? 50 20
	Using weights of 50 for homeworks, 20 for exam 1,  
	30 for exam 2.

	Homework:
	Number of assignments? 3
	Assignment 1 score and max? 14 15
	Assignment 2 score and max? 16 20
	Assignment 3 score and max? 19 25

	Number of labs attended? 4
	Total points = 65 / 80
	Weighted score = 40.63

	Exam 1:
	Score? 81
	Curve? 0
	Total points = 81 / 100
	Weighted score = 16.2

	Exam 2:
	Score? 95
	Curve? 10
	Total points = 100 / 100
	Weighted score = 30.0

	Course grade = 86.83
You may assume that the user enters valid input. For example, assume that the user enters a number of homework assignments no less than 1, and that the sum of category weights entered will be no more than 100. The weight of a particular category (homework, exam 1, or exam 2) will be non-negative but could be 0. You should handle the following two special cases of user input:
  1. A student might receive extra credit on a particular assignment, so for example 22 / 20 is a legal assignment score. But the total points for homework are capped at the maximum possible. For example if a student receives 63 total homework points out of a maximum of 60, your program should cap this to 60 / 60.
  2. The maximum score for an exam is 100. If the curved exam score exceeds 100, a score of 100 is used. Notice that all weighted scores and grades printed by the program are shown with no more than 2 digits after the decimal point. You should duplicate this behavior.