CS1301 Project 2- Grade Calculator Solved

35.00 $

Category: Tags: ,

Description

5/5 - (5 votes)

This project will allow you to apply your knowledge of decision statements, variables, assignments, string manipulation expressions, inputs, outputs, algorithm design, compiling, testing, and debugging source code. After completing this project, you’ll have your own program that may aid you in calculating your final numerical grade.

You will write a Java application called GradeCalculator in a file called GradeCalculator.java. This application will aid a student in calculating his/her current grade in the course as well as finding the average score (s)he will need to achieve a certain letter grade.

The following scale is used to compute the final letter grade in the course (we have omitted +/- letter grades for simplicity):

Letter Grade Point Range Meaning
A 90-100 Greater than or equal to 90 and less than or equal to 100
B 80-89 Greater than or equal to 80 and less than 90
C 70-79 Greater than or equal to 70 and less than 80
D 60-69 Greater than or equal to 60 and less than 70
F Below 60 Less than 60

 

The final grade for the course will be based on the student’s performance in Exam 1, Exam 2, Final Exam, Labs, Quizzes, Projects, and Participation.  Your program should prompt the user for the final letter grade (s)he wants to obtain for the course.  Then, the program should prompt the user to enter the weight each grading item carries.

Afterwards, the program prompts the user if (s)he knows the score for each grading item in the course.  If the user enters “y” or “yes”(ignoring capitalization), the program asks him/her the score for that grading item. Any other response is treated as a “no”.  The scores for each grading item are out of 100.  When prompting the user for the exam scores, the program should not prompt the user for exam 2 or the final exam if the user does not know the score for exam 1.  Similarly, if exam 2 is not known then the program does not prompt for the final exam score.

 

Once the user has entered his/her desired final letter grade, the weights of all grading items and his/her known scores, the program calculates and displays the current grade based on the current scores only using the following formula:

𝑤𝑤𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐𝑔𝑔𝑔𝑔 ∗ 𝑠𝑠𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑔𝑔𝑔𝑔

𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 =

𝑐𝑐𝑐𝑐𝑐𝑐𝑡𝑡𝑡𝑡𝑡𝑡𝑐𝑐𝑐𝑐𝑤𝑤𝑐𝑐𝑡𝑡𝑐𝑐𝑡𝑡𝑡𝑡𝑐𝑐𝑡𝑡𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐

where

  • weightgi: the weight of grading item gi
  • scoregi: the score achieved in the grading item gi
  • totalKnownGradeWeight: sum of weights of the grading items of known scores

For example, suppose that the user wants to get an A for the course and (s)he only knows his/her scores for Exam 1 and Exam 2, 92 and 85 respectively.  Moreover, Exam 1 carries 15% weight and Exam 2 carries 20% weight.  So the user’s current score is calculated as:

𝑤𝑤𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸1 ∗𝑠𝑠𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸1 + 𝑤𝑤𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸2 ∗𝑠𝑠𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸2

𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 =

𝑤𝑤𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸1 + 𝑤𝑤𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸2

Replacing the scores and percent weights by the user’s scores and percent weight in the previous formula, the user’s current score is:

𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐

*Hint: Dividing integers may give us unexpected results.

Then, the user’s current letter grade is determined by checking the range his/her current score falls in the course’s grade scale above.  The program will display the current score and grade letter for the user.  Moreover, if the user has entered a score for all the course grading items, the program should indicate in the message that score and letter grade corresponds to his/her final score and final letter.  In the example above, the user’s current letter grade is a ‘B’ according to the course’s grading scale.

The formula to calculate the grade average to obtain a final overall score is as follows:

100 ∗ 𝑓𝑓𝑒𝑒𝑐𝑐𝑡𝑡𝑡𝑡𝑓𝑓𝑎𝑎𝑐𝑐𝑐𝑐𝑡𝑡𝑡𝑡𝑡𝑡𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 − ∑𝑤𝑤𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐𝑔𝑔𝑔𝑔 ∗𝑠𝑠𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑔𝑔𝑔𝑔

𝑡𝑡𝑎𝑎𝑒𝑒𝑎𝑎𝑐𝑐𝑎𝑎𝑒𝑒𝑐𝑐𝑡𝑡𝑡𝑡𝑙𝑙𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑡𝑡𝑐𝑐𝑡𝑡𝑡𝑡𝑐𝑐 =

100 − 𝑐𝑐𝑐𝑐𝑐𝑐𝑡𝑡𝑡𝑡𝑡𝑡𝑐𝑐𝑐𝑐𝑤𝑤𝑐𝑐𝑡𝑡𝑐𝑐𝑡𝑡𝑡𝑡𝑐𝑐𝑡𝑡𝑐𝑐𝑒𝑒𝑒𝑒ℎ𝑐𝑐

  • finalOverallScore: minimum score in the range of the letter grade the user wants to achieve in the course.
  • weightgi: the weight of the grading item gi.
  • scoregi: the score achieved in the grading item gi.
  • totalKnownGradeWeight: sum of weights of grading items with known scores. Note: if this value is 100 then all grades are known and you should not do the calculation (as it results in a divide by zero).

The desired letter grade is achievable if the average score for the remaining grading items is not greater than a 100.  If the user’s desired letter grade is achievable in this semester for the student, the program prints the average score for the student to get that final letter grade.  Otherwise, it prints that the user cannot achieve that letter grade for the course.

In our example, the user would like to obtain an A.  Therefore, according to the previous formula, (s)he then needs to score a grade average greater than or equal to 91.07692 for the labs, quizzes, projects, participation, and final exam to obtain an A for the course.

Your program must display the grade average with two decimal places.  If the computed average score is not exact at the second decimal place, your program should add 0.01 to the average score and then display the result with two decimal places.  Alternatively, you could do some math (multiply, divide) and use Math.floor() or Math.ceil().  In the previous example, the program will display 91.08.

Requirements

  1. The name of the class in your Java program must be GradeCalculator. Therefore, the Java source code file must be called java.
  2. You should try to make your program look just like the examples below when you run your program with the same input.
  3. The input must be specified in the same order as indicated in the examples. This may seem like a minor detail but variations can cause problems for the graders – especially if they are automating the grading.
  4. The desired final letter grade entered by the user should be either A, B, C, D or F (upper or lower case). Otherwise, the program will display an error message and terminate immediately.   Throwing an exception is not an acceptable error message.
  5. If the weights entered for the course grading items do not add up to a 100, your program should display “Weights don’t add up to 100, program exiting…” and exit immediately.
  6. Your program should be able to process the answers to yes/no questions regardless of the case. Moreover, if the user does not input yes, y, no or n to a yes/no question, the program assumes that the answer is No (example output below).
  7. If the user enters a score for all values then you know the final grade. In this case, you should indicate whether or not they received the grade they wanted (example output below).
  8. You can safely assume the user will always enter a grade score as an integer between 0 and 100.
  9. You can safely assume the user will always enter a non-negative percent weight as an integer between 0 and 100.
  10. The current user’s score as well as the average score to obtain the user’s desired final letter grade must be displayed with at most two decimal places.
  11. Think about what it means if the avgToFinalLetterGrade is a negative value. Handle this case with an appropriate output (it’s not an error).
  12. You must include the Statement of Academic Honesty comment at the top of the program’s source file. Copy and agree to the entirety of the text contained in the file txt on the Labs and Projects webpage, and fill in the class name of your .java file, your name, submission date, and the program’s purpose.

In the future, every Java source file of every project you submit must have a comment such as this at the top of every source file.  Otherwise, points will be deducted from your project

  • project02-gensur.zip