
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 name
- double availablePoints
- double earnedPoints
The constructor heading should be:
public Assignment(String name, double availablePoints, double earnedPoints)Test class
The Test class should have the following instance variable:
- String testDate
The constructor heading should be:
public Test(String name, double availablePoints, double earnedPoints, String testDate)Project class
The Project class should have the following instance variables:
- String dueDate
- boolean groups
The constructor heading should be:
public Project(String name, double availablePoints, double earnedPoints, 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 1.6 Slides
Sample Output
Please enter an assignment name (exit to quit): Array Test Please enter the available points: 100 Please enter the earned 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 earned 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.14285714285714Also Note: Your output must contain the phrase Your Average: to pass the autograder.
{
}
}
import java.util.*;
public class AssignmentRunner {
public static void main(String[] args) {
// Start here
}
public static double average(ArrayList<Assignment> assignments) {
}
}
----------------------------------------------
public class Test extends Assignment {
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- The non-static class level variables and non-static methods of a class are known as a. instance members b. object behaviors c. object attributes O d. object referencesarrow_forwardHelp, I making a elevator simulator. I have to use polymorphism and object oriented programming to write this code. Can someone please help me improve this code I have. The remaining code is in the pictures. Any help is appreciated. Thank You! The simulation should have 4 types of Passengers: Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements. VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators. Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators. Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. The simulation should also have 4 types…arrow_forwardThe ability to create classes with more specific attributes and methods that share the properties and methods of existing classes is referred to as: Abstraction Polymorphism Typecasting Inheritancearrow_forward
- The Essay class has a default constructor, a constructor with two parameters, and a constructor with three parameters. Declare the following objects: essay1 with no arguments essay2 with essayTitle and essayAuthor as arguments essay3 with essayTitle, essayAuthor, and essayYear as arguments Ex: If the input is Painting Cole 1919, then the output is: Essay: Undefined, Unspecified, 0 Essay: Painting, Cole, 0 Essay: Painting, Cole, 1919 Archive.java public class Archive { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); StringessayTitle; StringessayAuthor; intessayYear; essayTitle=scnr.next(); essayAuthor=scnr.next(); essayYear=scnr.nextInt(); /* Your code goes here */ essay1.print(); essay2.print(); essay3.print(); } } Essay.java public class Essay { private String title; private String author; private int year; public Essay() { // Default constructor title = "Undefined"; author = "Unspecified"; year = 0; }…arrow_forwardThe language is Python Build a UML Diagram for the CellPhone class (The picture attatched below is what you need to reference when answering the question.)arrow_forward7. When a class contains objects of another class, the relationship is called a whole-part relationship or composition. The relationship created is also called a has-a relationship. Discuss some of the possible issues with composition, such as the long statement: Outputsales.getHighestPaidEmployee().getHireDate().getYear().arrow_forward
- What two characteristics distinguish the constructor from the class's methods, in your opinion?arrow_forwardConsider the following class definition: class circle { public: void print() const; void setRadius(double); void setCenter(double, double); void getCenter(double&, double&); double getRadius(); double area(); circle(); circle(double, double, double); double, double); private: double xCoordinate; double yCoordinate; double radius; } class cylinder: public circle { public: void print() const; void setHeight(double); double getHeight(); double volume(); double area(); cylinder(); cylinder(double, double, private: double height; } Suppose that you have the declaration: cylinder newCylinder; Write the definitions of the member functions of the classes circle and cylinder. Identify the member functions of the class cylinder that overrides the member functions of the class circlearrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





