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:
  1. Declare and initialize the following variables of type double:
  2. Instantiate a Scanner object to read from the keyboard.
  3. Use System.out.print to display the prompt "First assignment: ".
  4. Use the Scanner to read a double value from the user into assign0.
  5. Repeat for the second and third assignments, adjusting the prompts.
  6. Use System.out.print to display the prompt "First lab: ".
  7. Use the Scanner to read a double value from the user into lab0.
  8. Repeat for the second, third, and fourth labs, adjusting the prompts.
  9. Use System.out.print to display the prompt "First exam: ".
  10. Use the Scanner to read a double value from the user into exam0.
  11. Repeat for the second exam, adjusting the prompt.
  12. Compute the average assignment score and assign to assignAverage.
  13. Compute the average lab score and assign to labAverage.
  14. Compute the average exam score and assign to examAverage.
  15. Compute the class grade based on the following formula:
    		class grade = (assignment average * 30%) + (lab average * 20%) + (exam average * 50%)
    	
  16. Print the assignment average, as shown in the output below.
  17. Print the lab average, as shown in the output below.
  18. Print the exam average, as shown in the output below.
  19. Print the class grade, as shown in the output below.
  20. All output should have exactly 2 digits after the decimal point. (HINT: use System.out.printf)
  21. 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:

Grading Criteria

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.