[Solved] Lab 8

30 $

File Name: Lab_8.zip
File Size: 47.1 KB

SKU: [Solved] Lab 8 Category: Tag:

Or Upload Your Assignment Here:


Instructions:

  • Upload your solution to the link provided on the course page.
  • Create one NetBeans project for the 2 problems below. The project name should be Project Name: Lab8_<lastname_firstname>

Example: Lab8_Blanco_Maria

  • Compress the NetBeans project into .rar or .zip format.
  • The class names to be created are specified in each problem.
  • There should only be one main class (the class that contains the main method) where the implementation of the 2 problems will be done. Name it as Lab8Main. Follow the project structure below.
  • Only NetBeans project compressed in .rar or .zip format will be accepted.
  1. Extending StudentRecord

Class Names: Lab8Main (main class)

StudentRecord

ComputerScienceStudentRecord

The StudentRecord class is given for your reference. The following are your tasks:

  • Overload the StudentRecord constructor with one that accepts 4 parameters namely the name, mathGrade, englishGrade and scienceGrade.
  • Create a class that will inherit the attributes and methods of the StudentRecord class and name it ComputerScienceStudentRecord. Use the extends keyword for inheritance.
  • The ComputerScienceStudentRecord class will only have a comprogGrade attribute of double data type. Its constructor should accept 5 parameters namely the name, mathGrade, englishGrade, scienceGrade and comprogGrade.
  • Inside the ComputerScienceStudentRecord constructor, use the super keyword to call on the constructor of the StudentRecord and be able to assign the first 4 parameters. The value of the last parameter will be assigned to comprogGrade.
  • Override the computeAverageGrade method of the StudentRecord class in the ComputerScienceStudentRecord class. The result should be the average grade from the 4 subjects, Math, English, Science and Computer Programming.
  • Create a class that would contain the main method and name it Lab8Main. In the main method, instantiate a ComputerScienceStudentRecord object that has 5 parameters. The sample output is shown below.

public class StudentRecord {

//these are the attributes

private String name;

private double mathGrade;

private double englishGrade;

private double scienceGrade;

//this is the constructor

public StudentRecord(){

this.name=””;

this.mathGrade=0;

this.englishGrade=0;

this.scienceGrade=0;

}

Course Code Type Course Code Here
Description Computer Programming 2
College / Department:Online Education LaboratoryExercise No. 008
LABORATORY EXERCISE Page 2 of 4

//these are the mutators and accessors

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getMathGrade() {

return mathGrade;

}

public void setMathGrade(double mathGrade) {

this.mathGrade = mathGrade;

}

public double getEnglishGrade() {

return englishGrade;

}

public void setEnglishGrade(double englishGrade) {

this.englishGrade = englishGrade;

}

public double getScienceGrade() {

return scienceGrade;

}

public void setScienceGrade(double scienceGrade) {

this.scienceGrade = scienceGrade;

}

//custom method

public double computeAverageGrade(){

return (this.mathGrade + this.englishGrade + this.scienceGrade)/3;

}

}

Course Code Type Course Code Here
Description Computer Programming 2
College / Department:Online Education LaboratoryExercise No. 008
LABORATORY EXERCISE Page 3 of 4

Sample Output:

Course Code Type Course Code Here
Description Computer Programming 2
College / Department:Online Education LaboratoryExercise No. 008
LABORATORY EXERCISE Page 4 of 4
  1. The Shape Abstract Class

Classes Names: Lab8Main (main class)

Shape

Circle

Square

Create an abstract class called Shape with abstract methods getArea() and getName(). Write two of its subclasses Circle and Square. Override these methods in the Circle and Square classes. In the main method (LabExercise8 class), instantiate an object of the Circle class of radius 4 units, and an object of the Square class of side 5 units. The sample output is shown for your reference.

Sample Output:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Lab 8
30 $