Answered You can hire a professional tutor to get the answer.

QUESTION

Implement and test a HeighAndWeight class as given in the lecture notes. The class should include:

Implement and test a HeighAndWeight class as given in the lecture notes.

The class should include:

  • Private variables of type double for height and weight
  • A constructor that is passed an initial height (in inches) and weight (in pounds).
  • Getter methods (but no setter methods, i.e., make an immutable type)
  • A toString method
  • A BMI method (returning type double)
  • A healthyBMI method (returns true only if BMI in normal range - see Wikipedia)
  • A getDescript method (returns either "underweight", "normal", "overweight", or "obese
  • (based on what provided in Wikipedia)
  • A convertToMetric method that returns a new HeightAndWeight object containing the
  • height and weight in meters and kilograms
  • In addition, the following private method should be created called by the public methods for any needed conversions,
  • convertToMeters - returns the current height converted to meters (return type double)
  • convertToKgs - returns the current weight converted to meters (return type double)
  • STAGE 2
  • Develop a simple program that creates objects of type HeightAndWeight and tests that all aspect of the
  • HeightAndWeight class function correctly. Such a program is called a test driver.
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question