CS 160, Spring 2015
Programming Assignment P3
Grade Calculator
Programming due Monday, Feb. 9 at 6:00pm; late deadline Feb. 9 at 11:59pm.
Objectives
This programming assignment has the goal to help you further understand
the Java Scanner class for input, and to practice some simple arithmetic
expressions.
Description
This program requires the user to input 3 assignment scores, 4 lab scores, and
2 exam scores. After data entry, the program computes the average score for
each category, and the class grade, which is a weighted average
described below.
Instructions
For this assignment, you must follow directions exactly. Create a P3 project in Eclipse
then write a class P3 with a main method, and put all of the following code into the main method:
- Declare and initialize the following variables of type double:
- assign0, assign1, assign2
- lab0, lab1, lab2, lab3
- exam0, exam1
- assignAverage, labAverage, examAverage
- classGrade
- Instantiate a Scanner object to read from the keyboard.
- Use System.out.print to display the prompt "First assignment: ".
- Use the Scanner to read a double value from the user into assign0.
- Repeat for the second and third assignments, adjusting the prompts.
- Use System.out.print to display the prompt "First lab: ".
- Use the Scanner to read a double value from the user into lab0.
- Repeat for the second, third, and fourth labs, adjusting the prompts.
- Use System.out.print to display the prompt "First exam: ".
- Use the Scanner to read a double value from the user into exam0.
- Repeat for the second exam, adjusting the prompt.
- Compute the average assignment score and assign to assignAverage.
- Compute the average lab score and assign to labAverage.
- Compute the average exam score and assign to examAverage.
- Compute the class grade based on the following formula:
class grade = (assignment average * 30%) + (lab average * 20%) + (exam average * 50%)
- Print the assignment average, as shown in the output below.
- Print the lab average, as shown in the output below.
- Print the exam average, as shown in the output below.
- Print the class grade, as shown in the output below.
- All output should have exactly 2 digits after the decimal point. (HINT: use System.out.printf)
- Do not hard code anything, we will use different input values
than those shown. You should also test your program on a range of
different values. Use a calculator to check your answers.
Sample output
Your program's output should match the example shown below, user input is shown in blue:
First assignment: 11
Second assignment: 22
Third assignment: 33
First lab: 44
Second lab: 55
Third lab: 66
Fourth lab: 77
First exam: 88
Second exam: 99
Assignment average: 22.00
Lab average: 60.50
Exam average: 93.50
Class grade: 65.45
Specifications
Your program must meet the following specifications:
- Work on your own, as always.
- The name of the source code file must be exactly P3.java.
- Name the file exactly - upper and lower case matters!
- Comments at the top as shown in P1 and P2.
- Assignments should be implemented using Eclipse and Java 1.5 or 1.6 or 1.7.
- Make sure your code runs on machines in the COMSC 120 lab.
- Submit your program to the Checkin tab as you were shown in the recitation.
- Read the syllabus for the late policy.
Grading Criteria
- 100 points for perfect submission.
- 0 points for no submission, will not compile, submitted class file, etc.
- Preliminary Tests
- testCompile: checks that program compiles. (0 points)
- test1: checks the input of assignment scores. (10 points)
- test2: checks the input of lab scores. (10 points)
- test3: checks the input of exam scores. (10 points)
- test4: checks the calculation and output of the assignment average. (10 points)
- test5: checks the calculation and output of the lab average. (10 points)
- test6: checks the calculation and output of the exam average. (20 points)
- Preliminary testing uses the values shown above.
- Final Tests
- test7: checks the calculation and output of the class total, using the values shown. (10 points)
- test8: checks the assignment, lab, and exam averages using our own data. (10 points)
- test9: checks the calculation and output of the class total, using our own data. (10 points)
- Final testing includes the preliminary testing.
Submit your program to the Checkin tab on the course website, as you were shown in
the recitation, and read the syllabus for the late policy (if necessary).
© 2014 CS160 Colorado State University. All Rights Reserved.