Knowee
Questions
Features
Study Tools

In a course, a teacher gives the following tests and assignments:✓ A lab activity that is observed by the teacher and assigned a numeric score.✓ A pass/fail exam that has 10 questions. The minimum passing score is 70.✓ An essay that is assigned a numeric score.✓ A final exam that has 50 questions.Write a class named CourseGrades. The class should have a GradedActivity array named gradesas a field. The array should have four elements, one for each of the assignments previouslydescribed. The class should have the following methods:setLab: This method should accept a GradedActivity object as its argument. This object shouldalready hold the student’s score for the lab activity. Element 0 of the grades field should referencethis object.setPassFailExam: This method should accept a PassFailExam object as its argument. This objectshould already hold the student’s score for the pass/fail exam. Element 1 of the grades fieldshould reference this object.setEssay: This method should accept an Essay object as its argument. (See ProgrammingChallenge 4 for the Essay class. If you have not completed Programming Challenge 4, use aGradedActivity object instead.) This object should already hold the student’s score for the essay.Element 2 of the grades field should reference this object.setFinalExam: This method should accept a FinalExam object as its argument. This object shouldalready hold the student’s score for the final exam. Element 3 of the grades field should referencethis object.toString: This method should return a string that contains the numeric scores and grades for eachelement in the grades array.Demonstrate the class in a program

Question

In a course, a teacher gives the following tests and assignments:✓ A lab activity that is observed by the teacher and assigned a numeric score.✓ A pass/fail exam that has 10 questions. The minimum passing score is 70.✓ An essay that is assigned a numeric score.✓ A final exam that has 50 questions.Write a class named CourseGrades. The class should have a GradedActivity array named gradesas a field. The array should have four elements, one for each of the assignments previouslydescribed. The class should have the following methods:setLab: This method should accept a GradedActivity object as its argument. This object shouldalready hold the student’s score for the lab activity. Element 0 of the grades field should referencethis object.setPassFailExam: This method should accept a PassFailExam object as its argument. This objectshould already hold the student’s score for the pass/fail exam. Element 1 of the grades fieldshould reference this object.setEssay: This method should accept an Essay object as its argument. (See ProgrammingChallenge 4 for the Essay class. If you have not completed Programming Challenge 4, use aGradedActivity object instead.) This object should already hold the student’s score for the essay.Element 2 of the grades field should reference this object.setFinalExam: This method should accept a FinalExam object as its argument. This object shouldalready hold the student’s score for the final exam. Element 3 of the grades field should referencethis object.toString: This method should return a string that contains the numeric scores and grades for eachelement in the grades array.Demonstrate the class in a program

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple implementation of the CourseGrades class in Java:

public class CourseGrades {
    private GradedActivity[] grades;

    public CourseGrades() {
        grades = new GradedActivity[4];
    }

    public void setLab(GradedActivity aLab) {
        grades[0] = aLab;
    }

    public void setPassFailExam(PassFailExam aPassFailExam) {
        grades[1] = aPassFailExam;
    }

    public void setEssay(Essay anEssay) {
        grades[2] = anEssay;
    }

    public void setFinalExam(FinalExam aFinalExam) {
        grades[3] = aFinalExam;
    }

    @Override
    public String toString() {
        String result = "";
        for (int i = 0; i < grades.length; i++) {
            result += "Test " + (i + 1) + " score: " + grades[i].getScore() + ", grade: " + grades[i].getGrade() + "\n";
        }
        return result;
    }
}

This class has an array grades to hold the scores for the lab, pass/fail exam, essay, and final exam. The setLab, setPassFailExam, setEssay, and setFinalExam methods are used to set the scores for each of these components. The toString method is overridden to return a string that contains the numeric scores and grades for each element in the grades array.

Please note that this code assumes the existence of GradedActivity, PassFailExam, Essay, and FinalExam classes. You would need to define these classes with appropriate methods and fields as per your requirements.

To demonstrate the class in a program, you would create an instance of CourseGrades, set the scores for the lab, pass/fail exam, essay, and final exam using the appropriate methods, and then print the CourseGrades object.

This problem has been solved

Similar Questions

Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F

Code 1 Copy this code, compile and run it so you can answer the questions. import java.util.Scanner; public class UserGradingSystem { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Prompt user to enter scores for three subjects System.out.print("Enter math score: "); int mathScore = scanner.nextInt(); System.out.print("Enter science score: "); int scienceScore = scanner.nextInt(); System.out.print("Enter English score: "); int englishScore = scanner.nextInt(); // Calculate the average score int averageScore = (mathScore + scienceScore + englishScore) / 3; // Determine the overall grade if (averageScore >= 90) { System.out.println("Outstanding!"); } else if (averageScore >= 80) { System.out.println("Very Good!"); } else if (averageScore >= 70) { System.out.println("Good"); } else { System.out.println("Needs improvement"); } } } What if the user enters "85," "90," and "88," but mistakenly adds a semicolon after the English score, entering "88;"? (Refer to Code 1) Group of answer choices The program outputs "Needs improvement" for the invalid score. The program handles it gracefully, treating the input as valid. The program outputs "Outstanding!" for the valid scores. The program crashes with a runtime exception.

Develop the solutions to the following problems in the form of algorithms Determining whether to assign a pass or fail grade to a student depending on his/her exam mark Determining whether to assign A-F grade to student depending on his/her exam mark Determining what month it is depending on an integer value 1-12 that is entered Determining whether it will rain or not depending on if it is sunny or not**

Check the following Java program carefully. What should be written in the blank? Choose from the given options.                                        public class Test {  public static void main(String[] args) {    System.out.print("The grade is " + getGrade(78.5));    System.out.print("\nThe grade is " + getGrade(59.5));  }  public static ________ getGrade(double score) {    if (score >= 90.0)      return 'A';    else if (score >= 80.0)      return 'B';    else if (score >= 70.0)      return 'C';    else if (score >= 60.0)      return 'D';    else      return 'F';  }}Group of answer choicesvoidStringintchar

You have a class consisting of 5 students, each with a unique name and their respective marks. As the end of the semester approaches, you decide to assess the performance of your students and recognize their academic achievements.You write a Python program to categorize the students into different grades based on their marks. The program utilizes a Grade_analyzer class to represent each student and a StudentGradeAnalyzer function to analyze their grades. The function iterates through the list of students, calculates their grades and returns a dictionary containing the count of students in each grade.For grading:Students scoring between 80-100 will be in Grade A.Students scoring between 70-80 will be in Grade B.Students scoring between 60-70 will be in Grade C.Students scoring between 50-60 will be in Grade D.Students scoring below 50 will be in Grade E.Constraints:Input Format:5 lines of input, each line containing name and marks of each student.Ouptut Format:Should display items in dictionary which is holding Grades as keys and count of students falling under the grades as values.Example:Input:john 78missy 89sheldon 90mary 45meemaw 67Output:('A', 2)('B', 1)('C', 1)('D', 0)('E', 1)Explanation:input:--------Space saperated input name and marks for all the 5 students.john 78-->78 Falls into a range 70-80 so count of grade 'B' should be increased to 1.missy 89-->89 Falls into a range 80-100 so count of grade 'A' should be increased to 1.sheldon 90-->90 Falls into a range 80-100 so count of grade 'A' should be increased to 2.mary 45-->45 is less than 50 so count of grade 'E' should be increased to 1.meemaw 67-->67 Falls into a range 60-70 so count of grade 'C' should be increased to 1.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.