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

Body Mass Index Calculator App) The formulas for calculating the BMI are or Crea

ID: 3813908 • Letter: B

Question

Body Mass Index Calculator App) The formulas for calculating the BMI are or Create a BMI calculator app that allows users to enter their weight and height and whether they are entering these values in English or metric units, then calculates and displays the user’s body mass index. The app should also display the following information from the Department of Health and Human Services/National Institutes of Health so that users can evaluate their BMIs: BMI VALUES Underweight: less than 18.5 Normal: between 18.5 and 24.9 Overweight: between 25 and 29.9 Obese: 30 or greater BMI weightInPounds × 703 heightInInches × heightInInches = ------------------------------------------------------------------------------------ BMI weightInKilog rams heightInMeters × heightInMeters = -------------------------------------------------------------------------------------- must implement javaFX

Explanation / Answer

Ans: Programs include:

1.Controller.java

2.main.java

3.sample.xml

////////// programs /////////////////

///Program:: controller.java///

// package

package sample;

// javafx_button

import javafx.scene.control.Button;

// javafx_label

import javafx.scene.control.Label;

// javafx_Textfield

import javafx.scene.control.TextField;

// controller class

public class Controller {

// height_area

public TextField HeightArea;

// weight_area

public TextField WeightArea;

// Button_Calculate

public Button ButtonCalculate;

// Bmi_Label

public Label BmiLabel;

// Resul_tLabel

public Label ResultLabel;

// button_Click

public void buttonClick(){

// height-double

double height = Double.parseDouble(HeightArea.getText());

// weight-double

double weight = Double.parseDouble(WeightArea.getText());

// bmi_double

double bmi = weight/(height*height);

// label Bmi

BmiLabel.setText(String.format("Your BMI is %.2f", bmi));

// less than 18.5

if(bmi < 18.5){

// underweight

ResultLabel.setText("Underweight");

}

// greater than or equal to 18.5 and less than 25

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

// normal

ResultLabel.setText("Normal weight");

}

// greater than or equal to 25 and less than 30

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

// over_weight

ResultLabel.setText("Overweight");

}

// greater than 30

else if(bmi > 30){

// obesity

ResultLabel.setText("Obesity");

}

}

}

// program:: main.java ///

// package

package sample;

//javafx application

import javafx.application.Application;

//javafx FXMLLoader

import javafx.fxml.FXMLLoader;

// javax Parent

import javafx.scene.Parent;

// javafx Scene

import javafx.scene.Scene;

// javafx Stage

import javafx.stage.Stage;

// main extends Application

public class Main extends Application {

// override

@Override

// start and exception

public void start(Stage primaryStage) throws Exception{

// parent_root & load

Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));

// setTitle_BMICalc

primaryStage.setTitle("BMI Calculator");

// setScene 250 , 350

primaryStage.setScene(new Scene(root, 250, 350));

// show()

primaryStage.show(); // .show

}

// main_method

public static void main(String[] args) {

// launch_args

launch(args);

}

}

// program:: sample.fxml //

<!-- version & encoding -->

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

<?import javafx.geometry.*?> <!-- javafx geometry -->

<?import javafx.scene.control.*?> <!-- javafx control -->

<?import java.lang.*?> <!-- java lang -->

<?import javafx.scene.layout.*?> <!-- layout -->

<?import javafx.geometry.Insets?> <!-- Insets -->

<?import javafx.scene.layout.GridPane?> <!-- GridPane -->

<?import javafx.scene.control.Button?> <!-- javafx Button -->

<?import javafx.scene.control.Label?> <!-- javafx_Label -->

<!-- GridPane hgap-10 vgap-10 -->

<GridPane alignment="center" hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">

<!-- Column_constraints -->   

<columnConstraints>

<ColumnConstraints />

</columnConstraints>

<!-- row_Constraints -->

<rowConstraints>

<RowConstraints />

<RowConstraints />

</rowConstraints>

<!-- children-->

<children>

<!-- Anchor_pane height-350 width-250 rowIndex_1-->

<AnchorPane prefHeight="350.0" prefWidth="250.0" GridPane.rowIndex="1">

<children>

<!-- Height_area Weight_area Button bmi_label result_label design -->

<TextField fx:id="HeightArea" layoutX="27.0" layoutY="34.0" prefHeight="25.0" prefWidth="189.0" promptText="Enter Height in Meter" />

<TextField fx:id="WeightArea" layoutX="27.0" layoutY="78.0" prefHeight="25.0" prefWidth="189.0" promptText="Enter Weight in Kg" />

<Button fx:id="ButtonCalculate" layoutX="137.0" layoutY="123.0" mnemonicParsing="false" text="Calculate" />

<Label fx:id="BmiLabel" layoutX="46.0" layoutY="181.0" />

<Label fx:id="ResultLabel" layoutX="46.0" layoutY="211.0" />

<!-- closing children, Anchor_pane , Grid_pane tags -->

</children>

</AnchorPane>

</children>

</GridPane>