Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Provide a complete program that handles the entry and display of homework scores

ID: 3662730 • Letter: P

Question

Provide a complete program that handles the entry and display of homework scores. As part of your program, provide a HwScore class that contains the points earned on a particular homework and also the maximum possible points on that homework. In order to keep track of the overall average, the HwScore class also contains the total points earned on all homework combined and the total possible points on all homework combined. In order to determine letter grades, the HwScore class specifies cutoff values for the A, B, C, and D letter grades.

More specifically, the HwScore class should contain these constants and variables:

Named constants for the letter grade cutoffs: A = 0.9, B = 0.8, C = 0.7, D = 0.6

Class variables named totalEarnedPoints and totalPossiblePoints

Instance variables named earnedPoints and possiblePoints

The HwScore class should contain a two-parameter constructor that handles initializations for the earnedPoints and possiblePoints instance variables.

Implement a printGrade method that prints a particular homework’s earned points, possible points, and letter grade. The letter grade is based on this scale: A 90%, B 80%, C 70%, D 60%, F < 60%.

Implement a class method named printOverallGrade that prints the overall earned points, overall possible points, and overall letter grade.

Use appropriate modifiers for methods. The modifiers we’ve discussed so far are private, public, and static. Use helping methods when appropriate.

Provide a main driver method. It should:

Instantiate four HwScore objects and store them in the variables hw1, hw2, hw3, and hw4. In the instantiations, initialize the objects to these values:

hw1: 26.5 earned points, 30 possible points

hw2: 29 earned points, 27.5 possible points

hw3: 0 earned points, 20 possible points

hw4: 16 earned points, 20 possible points

For hw1, hw2, and hw3 (but not hw4), call printGrade.

Call printOverallGrade.

Output, using the main driver method described above:

On this homework, you earned 26.5 out of 30.0 possible points: B

On this homework, you earned 29.0 out of 27.5 possible points: A

On this homework, you earned 0.0 out of 20.0 possible points: F

On all homework, you earned 71.5 out of 97.5 possible points: C

As always, your program should mimic the output format precisely.

Explanation / Answer

public class YourNameProg2
{
public static void main (String[] args)
{
HwScore hw1 = new HwScore(26.5,30 );
HwScore hw2 = new HwScore(29,27.5 );
HwScore hw3 = new HwScore(0,20 );
HwScore hw4 = new HwScore(16,20 );

hw1.printGrade();
hw2.printGrade();
hw3.printGrade();

double overallEarnedPoints2 = hw1.earnedPoints + hw2.earnedPoints + hw3.earnedPoints;
double overallPossiblePoints2 = hw1.possiblePoints + hw2.possiblePoints + hw3.possiblePoints;

hw1.printOverallGrade(overallEarnedPoint... overallPossiblePoints2,3);


}
}


////////////////////////////////// second java file ////////////////////////

package hw;

public class HwScore
{

public double earnedPoints;
public double possiblePoints;

HwScore (double earnedPts, double possiblePts)
{
earnedPoints = earnedPts;
possiblePoints = possiblePts;

}

public void printGrade()
{
double percentageGrade = 0.0;
char letterGrade = ' ';
percentageGrade = (earnedPoints / possiblePoints) * 100;

if (percentageGrade >= 90)
{
letterGrade = 'a';
}
else if (percentageGrade >= 80 && percentageGrade < 90)
{
letterGrade = 'b';
}
else if (percentageGrade >= 70 && percentageGrade < 80)
{
letterGrade = 'c';
}
else if (percentageGrade >= 60 && percentageGrade < 70)
{
letterGrade = 'd';
}
else
letterGrade = 'f';

System.out.println(" This homework's earned points are: " + earnedPoints);
System.out.println("This homework's possible points are: " + possiblePoints);
System.out.println("This homework's letter grade is: " + letterGrade);
}

public void printOverallGrade(double overAllEarnedPoints, double overAllPossiblePoints, double totalAssignments)
{
// totalScores is the total of homework Assignments
double overAllEarnedPoints2 = overAllEarnedPoints;
double overAllPossiblePoints2 = overAllPossiblePoints;
double percentageGrade = 0.0;
char letterGrade = ' ';

percentageGrade = (overAllEarnedPoints2 / overAllPossiblePoints2) * 100;
if (percentageGrade >= 90)
{
letterGrade = 'a';
}
else if (percentageGrade >= 80 && percentageGrade < 90)
{
letterGrade = 'b';
}
else if (percentageGrade >= 70 && percentageGrade < 80)
{
letterGrade = 'c';
}
else if (percentageGrade >= 60 && percentageGrade < 70)
{
letterGrade = 'd';
}
else
letterGrade = 'f';


System.out.println(" Overall earned points are: " + overAllEarnedPoints2);
System.out.println("Overall possible points are: " + overAllPossiblePoints2);
System.out.println("Overall letter grade is: " + letterGrade);
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote