Question: Question: files: Test.java public class Test extends Assignment { private String testDate; public Test(String name, double availablePoints, double earnedPoints, String testDate) { super(name, availablePoints, earnedPoints);

Question:

Question: files: Test.java public class Test extends Assignment { private String testDate;

files:

  • Test.java
  • public class Test extends Assignment { private String testDate;

    public Test(String name, double availablePoints, double earnedPoints, String testDate) { super(name, availablePoints, earnedPoints); this.testDate = testDate; }

    public String getTestDate() { return testDate; }

    public void setTestDate(String testDate) { this.testDate = testDate; }

    }

  • Assignment.java
  • public class Assignment {

    private String name; private double availablePoints; private double earnedPoints; public Assignment(String name, double availablePoints, double earnedPoints) { super(); this.name = name; this.availablePoints = availablePoints; this.earnedPoints = earnedPoints; }

    public String getName() { return name; }

    public void setName(String name) { this.name = name; }

    public double getAvailablePoints() { return availablePoints; }

    public void setAvailablePoints(double availablePoints) { this.availablePoints = availablePoints; }

    public double getEarnedPoints() { return earnedPoints; }

    public void setEarnedPoints(double earnedPoints) { this.earnedPoints = earnedPoints; } }

  • Project.java
  • public class Project extends Assignment {

    private String dueDate; private boolean groups; public Project(String name, double availablePoints, double earnedPoints, String dueDate, boolean groups) { super(name, availablePoints, earnedPoints); this.dueDate = dueDate; this.groups = groups; }

    public String getDueDate() { return dueDate; }

    public void setDueDate(String dueDate) { this.dueDate = dueDate; }

    public boolean isGroups() { return groups; }

    public void setGroups(boolean groups) { this.groups = groups; } }

  • AssignmentRunner.java
  • import java.util.ArrayList; import java.util.List; import java.util.Scanner;

    public class AssignmentRunner { static List totalAssignments = new ArrayList(); static String assignmentName; static double availablePoints; static double earnedPoints; public static double average( List assignments) { double totalEarnedPoints=0,totalAvailablePoints=0; for (Assignment assignment : assignments) { totalAvailablePoints+= assignment.getAvailablePoints(); totalEarnedPoints+= assignment.getEarnedPoints(); } return (totalEarnedPoints / totalAvailablePoints * 100); }

    @SuppressWarnings("resource") public static void main(String[] args) { while (true) { Scanner scanner = new Scanner(System.in); System.out.println("Please enter an assignment name (exit to quit):"); assignmentName = scanner.nextLine(); if(assignmentName.equalsIgnoreCase("exit")) { System.out.println(" Exit.. "); System.out.println("Average is : " +average(totalAssignments)); System.exit(0); } System.out.println(" Please enter available points :"); availablePoints = scanner.nextInt(); System.out.println(" Please enter earned points :"); earnedPoints = scanner.nextInt(); System.out.println(" Is this a (t)est or (p)roject :"); String isThisType = scanner.next().toLowerCase(); if(isThisType.startsWith("t")) { System.out.println(" Please enter the test date :"); String testDate = scanner.next(); totalAssignments.add(new Test(assignmentName, availablePoints, earnedPoints, testDate)); System.out.println(); } else { System.out.println(" Please enter the due date :"); String dueDate = scanner.next(); System.out.println(" Group project? (true / false) :"); boolean groupProject = scanner.nextBoolean(); totalAssignments.add(new Project(assignmentName, availablePoints, earnedPoints, dueDate, groupProject)); System.out.println(); } } } }

I am getting multiple errors with this code from another chegg answer, could you please troubleshoot the code and explain? thank you!

In this lesson, we are going to create an Assignment superclass with a Test and Project Subclass Assignment class The Assignment class should have the following three instance variables: String nane double availablePoints double carnedPoints The constructor heading should be: public Assignment(String nane, double availablePoints, double carned oints) Test class The Test class should have the following instance variable: String testData The constructor heading should be: public Test(String name, double availablePoints, double carnedPoints, String testate) Project class The Project class should have the following instance variables: String debate boolean groups The constructor heading should be: public Project(String nane, double availablePoints, double carnedPoints, String dueDate, boolean groups) Each class should have getters and setters for each of its instance variables. AssignmentRunner class The AssignmentRunner should loop and prompt users for an assignment name until they enter exit. After getting the name, it should prompt the user for each of the pieces of information needed to create either a test or a project. Once the user has finished entering information, the program should call a static method to calculate the average (total points earned / total points available. 100). Note: Remember that the Scanner nextInt(). nextBoolean().and nextDouble() lines only read part of the line. Don't forget to use a nextLine() before reading a new string. Check out the slides for lesson 1.6 starting on Slide 21 for more details. Lesson 16 Slides Sample Output Please enter an assignment name (exit to quit): Array Test Please enter the available points: 100 Please enter the carned points: 95 Is this a (t)est or (p)roject: t Please enter the test date: 4/25 Please enter an assignment name (exit to quit): MadLibs Project Please enter the available points: 75 Please enter the carned points: 75 Is this a (t)est or (p)roject: p Please enter the due date: 4/15 Group project? true or false: true Please enter an assignment name (exit to quit): exit Your average: 97.14285714285714 Also Note: Your output must contain the phrase Your Average: to pass the autograder

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!