The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
| Â |
Course Code |
Type Course Code Here |
|
Description |
Computer Programming 2 |
|
|
College / Department: Online Education |
Laboratory Exercise No. |
008 |
|
LABORATORY EXERCISE |
Page 1 of 4 |
|
Â
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 theNetBeans 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:
1)Â Â Â Â Â Overload the StudentRecord constructor with one that accepts 4 parameters namely the name, mathGrade, englishGrade and scienceGrade.
Â
2)     Create a class that will inherit the attributes and methods of theStudentRecord class and name it ComputerScienceStudentRecord. Use the extends keyword for inheritance.
Â
Â
Â
Â
3)     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.
Â
4)     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.
Â
5)     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.
Â
6)     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
publicStudentRecord(){
       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 |
Laboratory Exercise 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() {
returnmathGrade;
   }
Â
public void setMathGrade(double mathGrade) {
this.mathGrade = mathGrade;
   }
Â
public double getEnglishGrade() {
returnenglishGrade;
   }
Â
public void setEnglishGrade(double englishGrade) {
this.englishGrade = englishGrade;
   }
Â
public double getScienceGrade() {
returnscienceGrade;
   }
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 |
Laboratory Exercise No. |
008 |
|
LABORATORY EXERCISE |
Page 3 of 4 |
|
Â
Â
Sample Output:
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
| Â |
Course Code |
Type Course Code Here |
|
Description |
Computer Programming 2 |
|
|
College / Department: Online Education |
Laboratory Exercise No. |
008 |
|
LABORATORY EXERCISE |
Page 4 of 4 |
|
2. 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:
Attachments:
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly