Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to make a GUI that uses JTextField, JLabel, and JButton. I need to write event handlers to process the user data. I also

I need to make a GUI that uses JTextField, JLabel, and JButton.

I need to write event handlers to process the user data.

I also must add the project that contains the HealthProfile class to this project (this is shown below).

This needs to be done in Java.

The HealthProfileGUI should have:

JTextField objects to enter: name, age, height in feet, height in inches, weight is pounds.

JButton objects to display the BMI, category, and max heart rate

JLabels to describe all textboxes.

Code event hanklers for each button:

Display - Make sure all user input is present and valid. Use the HealthProfile class to process data. Display the results on the GUI.

Clear - Clear all text boxes on the GUI.

public class HealthProfile

{

//attributes

private String name;

private short age;

private float weight;

private float height; // measured in total inches

//constructors

public HealthProfile()

{

name = "unknown";

age = 0;

weight = 0.0f;

height = 0.0f;

}

public HealthProfile(String name, short age, float weight, float height) {

this.name = name;

this.age = age;

this.weight = weight;

this.height = height;

}

// behaviors

public float getBMI()

{

return (float) ((weight * 703) / Math.pow(height, 2.0f));

}

public String getCategory()

{

float bmi = getBMI();

if( bmi < 18.5f )

return "Underweight";

else if( bmi >= 18.5 && bmi < 25)

return "Normal";

else if( bmi >= 25 && bmi < 30 )

return "Overweight";

else

return "Obese";

}

public float getMaxHR()

{

return 220 - age;

}

//getters and setters

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public short getAge() {

return age;

}

public void setAge(short age)

{

if( age > 0 && age < 150)

this.age = age;

else

this.age = 0;

}

public float getWeight() {

return weight;

}

public void setWeight(float weight)

{

if( weight > 0.0 && weight < 1000.0f )

this.weight = weight;

else

this.weight = 0.0f;

}

public float getHeight() {

return height;

}

public void setHeight(float height_feet, float height_inches)

{

this.height = (height_feet * 12) + height_inches;

}

}

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

What basic questions can HR analytics answer?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago