Question

Using JAVAFX The application will calculate Body Mass Index (BMI) for people. It must be able...

Using JAVAFX

The application will calculate Body Mass Index (BMI) for people. It must be able to accept as input weights (in pounds or kilos), and height (in inches or centimeters). The application should have a calculate button, and should display the result as well as if the data puts the person in one of 4 categories underweight ( BMI < 18.5) , normal weight (BMI 18.5-24.9), overweight (BMI 25.0 - 29.9) or overweight (BMI > 30) For full credit please submit the following:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

BMIController.java

package bmi;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;

public class BMIController implements Initializable {
  
@FXML
private Label label;
@FXML
private RadioButton pi;
@FXML
private RadioButton km;
@FXML
private TextField weight;
@FXML
private TextField height;
  
  
  
@FXML
private void handleButtonAction(ActionEvent event) {
try{
Double w = new Double(weight.getText());
Double h = new Double(height.getText());
Double bmi;
  
if(pi.isSelected()){
bmi = (w * 703.0)/(h*h);
label.setText(String.format("%.2f",bmi));
}
else if(km.isSelected()) {
bmi = w /(h*h);
label.setText(String.format("%.2f",bmi));
}
  
}catch(NumberFormatException nf){
weight.setText("Enter valid value");
weight.selectAll();
weight.requestFocus();
height.setText("Enter valid value");
height.selectAll();
  
}
  
}
  
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
  
}

BMI.java

package bmi;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class BMI extends Application {
  
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("BMI.fxml"));
  
Scene scene = new Scene(root);
stage.setTitle("BMI CALCULATOR");
stage.setScene(scene);
stage.show();
}

public static void main(String[] args) {
launch(args);
}
  
}

BMI.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="480.0" prefWidth="412.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="bmi.BMIController">
<children>
<Button fx:id="button" layoutX="155.0" layoutY="272.0" onAction="#handleButtonAction" text="Calculate" />
<Label fx:id="label" alignment="CENTER" layoutX="14.0" layoutY="381.0" minHeight="16" minWidth="69" prefHeight="64.0" prefWidth="180.0" text="0.0">
<font>
<Font name="System Bold Italic" size="24.0" />
</font></Label>
<TextArea layoutX="193.0" layoutY="319.0" prefHeight="147.0" prefWidth="206.0" text="BMI VALUES&#10;Underweight:&#9;less than 18.5&#10;Normal:&#9;&#9;between 18.5 and 24.9&#10;Overweight:&#9;between 25 and 29.9&#10;Obese:&#9;&#9;30 or greater&#10;">
<font>
<Font size="11.0" />
</font>
</TextArea>
<TextField fx:id="weight" layoutX="110.0" layoutY="145.0" />
<TextField fx:id="height" layoutX="110.0" layoutY="213.0" />
<RadioButton fx:id="pi" layoutX="60.0" layoutY="47.0" mnemonicParsing="false" selected="true" text="Pounds-Inches">
<toggleGroup>
<ToggleGroup fx:id="ip" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="km" layoutX="227.0" layoutY="47.0" mnemonicParsing="false" text="Kilograms-Meters" toggleGroup="$ip" />
<Label layoutX="119.0" layoutY="117.0" text="Weight" />
<Label layoutX="119.0" layoutY="190.0" text="Height" />
<Label layoutX="28.0" layoutY="319.0" prefHeight="50.0" prefWidth="152.0" text="Your BMI is:">
<font>
<Font size="24.0" />
</font>
</Label>
</children>
</AnchorPane>

Add a comment
Know the answer?
Add Answer to:
Using JAVAFX The application will calculate Body Mass Index (BMI) for people. It must be able...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program to calculate the Body Mass Index (BMI). The formulae to calculate the BMI...

    Write a program to calculate the Body Mass Index (BMI). The formulae to calculate the BMI are BMI = (weightinPounds x 703) / (heightinInches x heightinInches ) or BMI = weightinKilograms / (heightinMeters x heightinMeters ) Your program should read the user's weight in pounds and height in inches (or, Kilograms and meters, if you prefer), calculate and display the BMI. Your program should also display a message indicating how the BMI is evaluated, based on the following BMI values:...

  • OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is...

    OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is calculated by the formula EMENTS BMI = 7032 ATEMENT NESTED INTS where Wis weight in pounds, and His height in inches. The obesity classification is BMI Classification Below 18.5 Underweight 18.5 to 24.9 Normal 25 to 29.9 Overweight 30 and above Obese Tue Write a program in a script file that calculates the BMI of a person. The program asks the person to enter...

  • Body Mass Index Calculator

    Create a BMI calculator applications that reads the user's weight in kilograms and height in meters, then calculates and displays the user's body mass index.Also, the application should display the following information from the Department of Health and Human Services, so the user can evaluate his/her BMI:BMI ValuesUnderweight: less that 18.5Normal: between 18.5 and 24.9Overweight: between 25 and 29.9Obese: 30 or greaterFormula for calculating BMI areBMI = weightInKilogramsheightInMeters x heightInMetersThe program is to be written in C++ langauge.I need some...

  • javafx 1. Implement a BMI (Body Mass Index) server that will accept height and weight from...

    javafx 1. Implement a BMI (Body Mass Index) server that will accept height and weight from the client, calculate the BMI and return a string with the BMI and a status (l.e. normal, over weight, etc.). Build a GUI using JavaFX. You are given a working BMI class that will do the BMI calculations, etc. A single BMI client connection is sufficient. 2. Implement a JavaFX BMI client that will allow the user to enter height (in inches), weight (in...

  • 1. Your Body Mass Index (BMI) is a measure of your weight relative to your height....

    1. Your Body Mass Index (BMI) is a measure of your weight relative to your height. The formula can be found here: http://www.whathealth.com/bmi/formula.html (use the Imperial U.S. Method). Write an algorithm in pseudocode to calculate and display a person's BMI accepting as input their height in feet and inches and their weight in pounds. The output of your algorithm should be as follows: a. BMI b. A statement of whether the result is underweight, normal, overweight or obese.

  • BMI is often used to determine whether a person with a sedentary lifestyle is overweight or...

    BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for their height. A person’s BMI is calculated with the following formula: BMI = (weight * 703) / height2 In the formula, weight is measured in pounds and height is measured in inches. Create a VB application to calculate a user’s BMI by allowing users to enter their weight and height in the appropriate units. Display their BMI with an appropriate control. Display...

  • 5. A person's Body-Mass Index (BMI) is calculated by dividing weight (in kilograms) by height2 (in...

    5. A person's Body-Mass Index (BMI) is calculated by dividing weight (in kilograms) by height2 (in meters). According to the book, The Changing Body, the BMI values of non-Hispanic adult males in the United States are approximately Normally distributed with mean (μ)-265 and standard deviation (o)-4.0. Find the standardized scores associated with the thresholds between different categories. a. Underweight vs. Normal (BMI 18.5) b. Normal vs. Overweight (BMI 25) c. Overweight vs. Obese (BMI 30) 6. Combine the standardized scores...

  • The body mass index (BMI estimates the amount of fat in a person's body. It is defined as the person's mass m in kilograms divided by the square of the person's height h in meters. Write...

    The body mass index (BMI estimates the amount of fat in a person's body. It is defined as the person's mass m in kilograms divided by the square of the person's height h in meters. Write the formula for BMI in terms of m and h. 0 BMI In the United States, most people measure weight in pounds and height in feet and inches. When weight W is measured in pounds and height h is measured in inches, the BMI...

  • python2.7 25 Points. Create a class named BMIGUI with the following behavior. A template has been...

    python2.7 25 Points. Create a class named BMIGUI with the following behavior. A template has been provided for you and you cannot modify the template. You must use grid) to format the interface and you must get as close as possible the layout shown below. The entry box has a width parameter in its constructor you can use to make the box smaller 3. The BMI categories are as follows: Underweight= <18.5 Normal weight18.5-24.9 . Overweight 25-29.9 Obese BMI of...

  • /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...

    /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates the user's body-mass-index (BMI) // 3. and then prints an appropriate message based on the user's BMI /////////////////////////////////////////////////////////////////////////////////// #include <iostream> using namespace std; void printWelcome(); // ask the weight (in pounds) and height (in inches) of the user and store the values in formal // parameters weight and height, respectively void getWeightAndHeight(float& weight, float& height); // calculate and return the BMI (Body-Mass-Index) based on...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT