 |
CS 139
Algorithm Development
PA2: Grade Calculator - refactored
Part
A Due in Canvas by Wednesday, Feb 18 at 11:59PM
Part B Due in WebCAT by
Tuesday, Feb 24 at 11:59 PM
Late assignments will be accepted in accordance with the following penalties:
- -10% on Wednesday Feb 25
- -20% on Thursday Feb 26
- -30% on Friday Feb 27
- -40% on Sunday Mar 1
- -50% on Monday Mar 2
- Not accepted afterwards
Part C due in Canvas by
Wednesday Feb 26 or one day after you have successfully submitted to
WebCAT whichever is later.
|
UPDATES:
Objectives - At the conclusion of this assignment students will
have demonstrated that they can:
- Input data from a keyboard.
- Use Java math operations.
- Properly format output to specification.
- Divide a problem up into different modules and methods.
- Do everything necessary to create, debug, and run a java
program.
- Use comments to delineate each section of the program.
- Adhere to a Java Style Guide.
- READ AND FOLLOW DIRECTIONS!!!!!
Background
Students are frequently graded on the basis of "weighted" averages. Weighted averages value different kinds of work differently based on the syllabus requirements. For example, in this class, labs are worth 10% of the overall grade, while PAs are worth 20%. In this application you will prompt the user for the 6 grades in this class and then will produce a weighted average for the course. This application would let you try "what if" scenarios for your final grade in this class.
Requirements
PART A - Graded as a homework assignment. There
will be a separate Canvas Assignment for this.
This program will be refactored for this version. Instead of having a big "main" method, you are going to take some of the repetitive code in the program and make methods from them that can be reused when you need them. The "tools" or methods that you create will be stored in a separate file called, GradeCalculatorTools.java. For this assignment, you will fully stub out the GradeCalculatorTools.java file. (See Lab05B for your introduction to stubs). See the Design section for further information. NOTE: Stubbed out methods should include full documentation. Your stubs will be tested on whether or not they compile, whether or not they conform to the requirements of the assignment and on the completeness of the method documentation.
PART B - Submitted to webcat. WebCAT will be made available no later than Sunday morning Mar 1. NOTE: Each of your methods will be tested separately. Your methods must conform to the design requirements below.
You will write a single Java program, GradeCalculator, that must:
- Prompt for each of the grade values and read in the corresponding value.
- Prompt for the name of the class and the name of the student.
- Calculate the weighted average for the class. Weights are:
- Homework - 10%
- Labs - 10%
- Weekly quiz - 10%
- PAs - 20%
- Midterm 1 10%
- Midterm 2 15%
- Final Exam 25%
- Display the class, student name, grade values (with appropriate labels), and calculated average.
- All output labels (for categories and final average) will be right justified in a field that is 12 wide.
- All number amounts will be displayed in a field that is 6 wide with two decimal places.
A complete dialog as it would appear at the command line would look like this. (with input values highlighted in red would look
like)
Homework grade? 75.50
Lab grade? 82.5
Weekly quiz grade? 100
PA grade? 86.45
Midterm 1 grade? 95.5
Midterm 2 grade? 80.6
Final exam grade? 92.15
Class name? Programming Fundamentals
Student name? Nancy Harris
<blank>
Programming Fundamentals
Nancy Harris
<blank>
HW: 75.50
Lab: 82.50
WQ: 100.00
PAs: 86.45
Midterm 1: 95.50
Midterm 2: 80.60
Final exam: 92.15
-------------------
Final grade: 87.77
Output specifications
Prompts
- Each input prompt must use a print statement. There should be no new line character at the end of the prompt. Notice how the input is placed directly beside the corresponding prompt.
- You must use the exact verbiage as shown in the sample dialog.
- The prompts must be in the order shown.
- Each prompt ends with a question mark (?) and a single space.
Results
- Each line of result output should terminate with the new line character.
- Each line should use teh exact verbiage as found in the sample dialog.
- The first line of result output should be a blank line.
- The next line should print the name of the course.
- The next line should print the name of the student.
- There should be a blank line next.
- For each of the category lines, you will print the label including the colon in a line that is 12 characters wide. Each of the colons should line up. There should next be a single blank space. The grade should print in a field that is 6 wide, but if there is no hundreds number, the first character would be blank as shown. Each grade should include exactly 2 decimal places and the result should be rounded.
- After printing the Final Exam grade, display a line of hyphens as a separator.
- Output the calculated Final grade. This should be the weighted average of all of the grades.
NOTES:
- Since the weights mean something they should be constants.
- For this and every other PA, you should only create 1 Scanner object. Multiple Scanner instantiations (new Scanner...) will cause WebCAT to fail.
- Your program should use appropriate data types for the values being
input and calculated, and appropriate and meaningful names for all
variables and constants.
- The program source must follow all StyleGuide
conventions used in this class.
Design Requirements
- You must have two files, GradeCalculator.java which will contain a single static main method and GradeCalculatorTools.java that will contain the methods specified below. These methods will be non-static...in other words, to use these tools, you will need to create a GradeCalculatorTools object in GradeCalculator.
- NOTE: In first two methods, there is a requirement that you pass a Scanner to the method. It is important that you build a single Scanner in main and then pass that same Scanner to each of the method calls. Multiple Scanners will cause time out or other errors in WebCAT testing.
- You must have a method, promptGrade, which takes in as parameters (in this order), a Scanner and a String, and returns a double value. The Scanner should be built in GradeCalculator and passed to promptGrade. The String will be a prompt message. The method should prompt the user for the value desired using the String parameter, read in the value and return it. In addition, the method should "consume" the new line character left by the double read.
- You must have a method, promptText, which takes in parameters (in this order), a Scanner and a String, and returns a String. The Scanner should be built in GradeCalculator and passed to promptText. The String will be a prompt message. The method should prompt the user for the value desired using the String parameter, read in the entire line entered by the user and then return it. It should not consume the new line character.
- You must have a method, formatLabel, which takes in a String parameter and a width and returns the String right justified in a field of that width.
- You must have a method, formatGrade, which takes in a double parameter and returns a String which is the grade formatted in a field 6 wide with 2 decimal positions. (100.00 or _95.50) (I'm using an underscore to show where a space would be.)
- You may add additional methods if you feel that they will help you.
Part B Deliverables
- You should submit, GradeCalculator.java to via
Web-CAT (http://webcat.cs.jmu.edu).
You must package your files into a single zip package because you can only upload a single file to WebCAT.
- Your program will be judged on correctness (80%) and conformance
to the StyleGuide
(20%). Your program must pass all submission tests to be graded. The checkoff chart is found in Canvas in the Resources module..
Part C Reflection - graded as
a regular homework assignment. There will be separate Canvas Assignments
for this.
You will write a reflection document for this assignment which will
let you consider the process of building this program. It will also
contain a place to critique this assignment for this class.
Honor Code
This is an individual programming assignment. This assignment should
be viewed as a take home exam. Your work on the assignment and your
submission must conform to the JMU Honor Code.
Authorized help is limited to the classroom handouts, lab material, the
TAs for any CS139, our graduate student and the professor. Copying work
from another student or the Internet is an
honor code violation, which will result in a zero on the assignment and
possibly further sanctions. You may use the internet to search for help, but each site that you use hould be acknowledged in the Reference section of the code documentation.
Your work on this assignment is subject to
review by MOSS
which is a plagiarism detection tool for programs. Submission to WebCAT
constitutes your submission of work for academic credit and your
agreement that your work may be submitted to MOSS.