subject

Body Mass Index (BMI) is measure of weight that takes height into account. Generally, a BMI above 25 is considered high, that is, likely to indicate that an individual is overweight. BMI is calculated as follows for both men and women: 703 * weight in pounds / (height in inches)^2 Files BMI. java and BMIPanel. java contain skeletons for a program that uses a GUI to let the user compute their BMI. This is similar to the Fahrenheit program in listings 6.5 and 6.6 of the text.
Fill in the code as indicated by the comments and compile and run this program; you should see the BMI calculator displayed.
//
// BMI. java
//
// Sets up a GUI to calculate body mass index.
//
import javax. swing. JFrame;
public class BMI
{
//
// Creates and displays the BMI GUI.
//
public static void main (String[] args)
{
JFrame frame = new JFrame("BMI");
frame. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
BMIPanel panel = new BMIPanel();
frame. getContentPane().add(panel);
frame. pack();
frame. setVisible(true);
}
}
//
// BMIPanel. java
//
// Computes body mass index in a GUI.
//
import java. awt.*;
import java. awt. event.*;
import javax. swing.*;
public class BMIPanel extends JPanel
{
private int WIDTH = 300;
private int HEIGHT = 120;
private JLabel heightLabel, weightLabel, BMILabel, resultLabel;
private JTextField height, weight;
private JButton calculate;
//
// Sets up the GUI.
//
public BMIPanel()
{
//create labels for the height and weight textfields
heightLabel = new JLabel ("Your height in inches: ");
weightLabel = new JLabel ("Your weight in pounds: ");
//create a "this is your BMI" label
//create a result label to hold the BMI value
//create a JTextField to hold the person's height in inches
//create a JTextField to hold the person's weight in pounds
//create a button to press to calculate BMI
//create a BMIListener and make it listen for the button to be pressed
//add the height label and height textfield to the panel
//add the weight label and weight textfield to the panel
//add the button to the panel
//add the BMI label to the panel
//add the label that holds the result to the panel
//set the size of the panel to the WIDTH and HEIGHT constants
//set the color of the panel to whatever you choose
}
//
// Represents an action listener for the calculate button.
//
private class BMIListener implements ActionListener
{
//
// Compute the BMI when the button is pressed
//
public void actionPerformed (ActionEvent event)
{
String heightText, weightText;
int heightVal, weightVal;
double bmi;
//get the text from the height and weight textfields
//Use Integer. parseInt to convert the text to integer values
//Calculate the bmi = 703 * weight in pounds / (height in inches)^2
//Put result in result label. Format the result to display only 1 decimal position. (.25)
}
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 14:00
Which describes careers that have similar education requirements but different qualifications? product safety engineers and materials engineers industrial safety engineers and industrial health engineers quality control systems managers and inspectors industrial safety and health engineers and hand packers
Answers: 3
question
Computers and Technology, 24.06.2019 17:30
What is the main difference between cloud computing and saas? cloud computing is a platform, and saas is software. cloud computing is software, and saas is a platform. cloud computing is a service, and saas is software. cloud computing is a service, and saas is a platform.
Answers: 1
question
Computers and Technology, 24.06.2019 18:10
Most information security incidents will occur because of select one: a. users who do not follow secure computing practices and procedures b. increases in hacker skills and capabilities c. poorly designed network protection software d. increasing sophistication of computer viruses and worms
Answers: 1
question
Computers and Technology, 24.06.2019 19:20
Kiesha has a worksheet with a range of cells using the following columns: name, score, group, study group, and date. kiesha needs to sort the worksheet on the date field. which option she use to most efficiently complete this task ? a use the cut and paste option to reorganize the data to fit that order b use the filter function to organize the data based on the date c use the order function to organize the data based on the date d use the sort function to organize the data based on date order
Answers: 3
You know the right answer?
Body Mass Index (BMI) is measure of weight that takes height into account. Generally, a BMI above 25...
Questions
question
Chemistry, 02.08.2019 19:00
question
Mathematics, 02.08.2019 19:00
Questions on the website: 13722367