Computers and Technology

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)
}
}
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:20, sosick90501
Write a function balancechemical to balance chemical reactions by solving a linear set of equations. the inputs arguments are: reagents: symbols of reagents in string row array products: symbols of products in string row array elements: elements in the reaction in string row array elcmpreag: elemental composition of reactants in two dimensional numeric array elcmpprdcts: elemental composition of prducts in two dimensional numeric array hint: the first part of the problem is setting up the set of linear equations that should be solve. the second part of the problem is to find the integers from the solution. one way to do this is to mulitiply the rational basis for the nullspace by increasing larger integers until both the left-and right-side integers exist. for example, for the reaction that involves reacting with to produce and : reagents=["ch4", "o2"]; products =["co2", "h2o"]; elements =["c","h", "o"] elcmpreag=[1,4,0;
Answers: 3
image
Computers and Technology, 24.06.2019 03:40, Eylul30
4. does the kernel phenotype distribution support the idea that the cob is the result of a dihybrid cross? what information supports your answer? if a dihybrid cross (i. e. f1 to f2 of standard mendelian crosses) is not indicated what conditions might contribute to this finding.
Answers: 2
image
Computers and Technology, 24.06.2019 10:00, RG1971
(, urgent need): how do i change my username
Answers: 1
image
Computers and Technology, 24.06.2019 13:50, jaystarr9395
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun, i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
Do you know the correct answer?
Body Mass Index (BMI) is measure of weight that takes height into account. Generally, a BMI above 25...

Questions in other subjects:

Konu
History, 19.03.2020 02:27
Konu
Mathematics, 19.03.2020 02:27
Konu
Mathematics, 19.03.2020 02:27
Konu
Social Studies, 19.03.2020 02:27