Question
I do not have PassFailActivity.java The code isn't working. There are errors even though it seems correct. Your help is needed PassFailExam.java public class PassFailExam
I do not have PassFailActivity.java
The code isn't working.
There are errors even though it seems correct.
Your help is needed
PassFailExam.java
public class PassFailExam extends PassFailActivity { private int numOfQuestions;
private double pointsOfEach;
private int numOfMissed;
public PassFailExam(int questions, int missed, double minPassing) { super(minPassing);
double numericScoreValue;
numOfQuestions = questions; numOfMissed = missed;
pointsOfEach = 100.0/questions; numericScoreValue = 100.0 - (missed*pointsOfEach);
setScore(numericScoreValue); } public double getPointsOfEach() { return pointsOfEach; } public int getNumOfMissed() { return numOfMissed; } }
GradedActivity.java
public class GradedActivity { private double scoreValue;
public void setScore(double s1) { scoreValue = s1; } public double getScoreOf() { return scoreValue; } public char getGradeOf() { char letterGrade;
if(scoreValue >= 90) letterGrade ='A';
else if(scoreValue >= 80) letterGrade = 'B';
else if(scoreValue >= 70) letterGrade ='C';
else if(scoreValue >= 60) letterGrade ='D';
else letterGrade = 'F';
return letterGrade; } }
FinalExam.java
public class FinalExam extends GradedActivity { private int numOfQuestions;
private double pointsOfEach;
private int numOfMissed;
public FinalExam(int questions, int missed) { double numericScoreValue;
numOfQuestions = questions; numOfMissed = missed;
pointsOfEach = 100.0/questions; numericScoreValue = 100.0 - (missed*pointsOfEach);
setScore(numericScoreValue); }
public double getPointsOfEach() { return pointsOfEach; }
public int getNumOfMissed() { return numOfMissed; } }
Essay.java
public class Essay extends GradedActivity { private int grammars; private int spellings; private int correctLengths; private int contents;
public Essay(int egrammar, int espelling, int ecorrectLength, int econtent) { grammars = egrammar; spellings = espelling; correctLengths = ecorrectLength; contents = econtent;
setScore(grammars + spellings + correctLengths + contents); }
public int getgrammar() { return grammars; }
public int getSpelling() { return spellings; }
public int getCorrectLength() { return correctLengths; }
public int getContent() { return contents; }
}
CourseGrades.java
public class CourseGrades { private GradedActivity[] grades = new GradedActivity[4];
public void setLab(GradedActivity ga) { grades[0] = ga; }
public void setPassFailExam(PassFailExam pfe) { grades[1] = pfe; }
public void setEssay(Essay e) { grades[2] = e; }
public void setFinalExam(FinalExam fe) { grades[3] = fe; }
public String toString() { return "Lab: " + " Score: " + grades[0].getScoreOf() + " Grade: " + grades[0].getGradeOf() + " PassFailExam: " + " Score: " + grades[1].getScoreOf() + " Grade: " + grades[1].getGradeOf() + " Essay: " + " Score: " + grades[2].getScoreOf() + " Grade: " + grades[2].getGradeOf() + " FinalExam: " + " Score: " + grades[3].getScoreOf() + " Grade: " + grades[3].getGradeOf(); } }
CourseGradeDemo.java
public class CourseGradeDemo { public static void main(String[] args) { GradedActivity ga = new GradedActivity();
ga.setScore(60);
PassFailExam pfe = new PassFailExam(10, 3, 70);
Essay e = new Essay(28, 19, 18, 29);
FinalExam fe = new FinalExam(50, 12);
CourseGrades coursegrade = new CourseGrades();
coursegrade.setLab(ga);
coursegrade.setPassFailExam(pfe);
coursegrade.setEssay(e);
coursegrade.setFinalExam(fe);
System.out.println(coursegrade); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started