Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

plz help answer Comparable Suppose you have a pre-existing class Dieter that models a person trying to monitor diet and weight to improve his/her Body

plz help answer image text in transcribed
Comparable Suppose you have a pre-existing class Dieter that models a person trying to monitor diet and weight to improve his/her Body Mass Index (BMI) rating. The class has the following data and behavior: Field/Constructor/Method Description private String name the dieter's full name, such as "John Smith" private int height the dieter's height, in inches private int weight the dieter's weight, in pounds public Dieter(String name, int h, int w) makes a dieter with given name, height weight public String getName( returns the dieter's name public int getHeight returns the dieter's height public int getWeight returns the dieter's weight public double getBMIO computes the dieter's Body Mass Index (BMI). which is (weight/ beight2) 703 public void gain(int pounds) called when the dieter gains weight public void lose(int pounds) called when the dieter lose weight We want Dicter objects comparable to each other using the Comparable interface based on: Dieters are primarily compared by their BMI ratings, A dieter with a lower BMI is less than" one with a higher BMI If two dicters have the same BMI, the tie is broken by height, the shorter person is considered to be "less than the taller one If two dicters have the same BMI and height, the tie is broken by name. The dieter whose name comes first in alphabetical order is considered "less than the one whose name comes later in ABC order If the two dieters have the sathe BMI, height, and name, they are considered to be "equal." Being careful to use the correct case of letters, fill in the blank boxes with each portion of the comparable Dieter class header

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions