CS 160, Summer 2016
Programming Assignment P2
Grade Calculator

Programming due Monday, June 20 at 6:00pm; late deadline at 11:59 pm.


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 4 assignment scores, 3 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 P2 project in Eclipse then write a class P2 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, third, and fourth 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 and third 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 * 35%) + (lab average * 10%) + (exam average * 55%)
        
  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 total, 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
  Fourth assignment: 44
  First lab: 44
  Second lab: 55
  Third lab: 66
  First exam: 88
  Second exam: 99
  Assignment average: 27.50
  Lab average: 55.00
  Exam average: 93.50
  Class total: 66.55

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).

© 2016 CS160 Colorado State University. All Rights Reserved.