7.5k views
0 votes
Suppose you have a class called Child with an instance data value called weight and height. Then it has a method called doubleWeight that stores a local double variable called superWeight that multiplies the two instance variables and stores the value in superWeight, and this method returns a double value. Write a getter method and a setter method for weight, and then make them for height.

1 Answer

4 votes

Answer:

Step-by-step explanation:

The following code is written in Java. I recreated the entire Child class as described with the instance variables and the doubleWeight method. Then created the getter and setter methods for both the weight and height variables.

class Child {

double weight, height;

public double doubleWeight() {

double superWeight = weight * height;

return superWeight;

}

public double getWeight() {

return weight;

}

public void setWeight(double weight) {

this.weight = weight;

}

public double getHeight() {

return height;

}

public void setHeight(double height) {

this.height = height;

}

}

Suppose you have a class called Child with an instance data value called weight and-example-1
User Hbirjand
by
3.9k points