Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java class, called Fitness to maintain information about a person?s name

ID: 665598 • Letter: W

Question

Write a Java class, called Fitness to maintain information about a person?s name, age, weight and height. A name comprises a first name, a middle initial and a last name. Write a constructor for this class that initializes all attribute variables. No error checking of parameters is required for this question. In addition to the constructor, your class should implement the following three methods: . firstNamels takes a first name as a parameter and returns true if it is the same as this individual?s name. . bmi calculates the body mass index for this individual. The body mass index is a measure of relative weight defined as the individual?s body mass (weight) divided by the square of their height with units of kg/m^2. . bmiNormal returns true if the individual?s BMI is in the normal range and false otherwise. A normal BMI is defined as a value between 18.5 and 25. Include brief comments where necessary, but full Javadoc comments are not required.

Explanation / Answer

import java.util.*;
public class Fitness {
    private String firstName,middleName,lastName;
    private int age;
    private double weight,height;
    public Fitness(String first,String middle, String last,int a,double we,double he)
    {
        firstName=first;
        middleName=middle;
        lastName=last;
        age=a;
        height=he;
        weight=we;
    }
    public boolean firstNameIs(String first)
    {
        if(first==firstName)
            return true;
        else
            return false;
    }
    public double bmi()
    {
        double temp= (weight)/(height*height);
        return temp;
    }
    public boolean bmiNormal(double bmi)
    {
        if(bmi<=25 && bmi>=18.5)
            return true;
        else
            return false;
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote