Question: Java Programming. Need it in 30 minutes please Develop a Student class as a subclass of the Person class that contains the following additional values
Java Programming. Need it in 30 minutes please
Develop a Student class as a subclass of the Person class that contains the following additional values than those inherited from the Person class:
earned_credits (total number of earned credits)
gpa (current overall GPA)
major
Include in the class:
appropriate constructor
getter methods
toString method
getStatus (freshman, sophomore, junor, senior)
onDeansList (returns true if GPA >= 3.4)
Freshman status (0-30 earned credits), sophomore (31-60), etc.
Person.java
//Amjad Alsadiq
//Lab2
public final class Person {
private final String name;
private final int age;
private final HeightAndWeight height_weight;
public Person(String name, int age, HeightAndWeight height_weight) {
this.name = name;
this.age = age;
// Shallow Copy
// Deep Copy
HeightAndWeight hw = new HeightAndWeight();
hw.setHightInInches(height_weight.getHightInInches());
hw.setWeightInPounds(height_weight.getWeightInPounds());
this.height_weight = hw;
}
public double BMI() {
double height=height_weight.getHightInMeter();
double weight= height_weight.getWeightInKg();
return weight / Math.pow(height, 2);
}
public boolean isOverweight(double bmi) {
return (bmi >= 25.0);
}
public int getAge() {
return age;
}
public HeightAndWeight getHeight_weight() {
return height_weight;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "name=" + name + ", age=" + age + ", height_weight=" + this.height_weight.toString();
}
}
HeightAndWeight.java
public class HeightAndWeight {
private int hightInInches;
private int weightInPounds;
public HeightAndWeight() {
}
public HeightAndWeight(int hightInInches, int weightInPounds) {
this.hightInInches = hightInInches;
this.weightInPounds = weightInPounds;
}
//Conversions
public double inchestoMeters(int h) {
return (0.0254*h);
}
public double poundsToKg(int lbs) {
return (0.45359237*lbs);
}
public double getHightInMeter() {
return inchestoMeters(this.hightInInches);
}
public double getWeightInKg() {
return poundsToKg(this.weightInPounds);
}
@Override
public String toString() {
int feet= this.hightInInches/12;
int inches= this.hightInInches%12;
return (feet+ " ft "+inches+" ins. "+this.weightInPounds+" lbs.");
}
//Getters
public int getHightInInches() {
return hightInInches;
}
public int getWeightInPounds() {
return weightInPounds;
}
//Setters
public void setHightInInches(int hightInInches) {
this.hightInInches = hightInInches;
}
public void setWeightInPounds(int weightInPounds) {
this.weightInPounds = weightInPounds;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
