Question: We were first suppose to create a program to get a persons weight and height to calculate their BMI in a java program. now we
We were first suppose to create a program to get a persons weight and height to calculate their BMI in a java program. now we are suppose to make it stores it into an array with JTEXTFIELD and output it with GUI. the program should collect and caculate BMI up to 100 people.i am not sure how to do that.
import javax.swing.JOptionpane;
public class BMI {
public static void main(String[] args){ double weight; double height; double BMI; String keyboard; String name = JOptionPane.showInputDialog("Enter your Name"); keyboard = JOptionPane.showInputDialog("Enter your weight in pounds"); weight= Double.parseDouble(keyboard); keyboard = JOptionPane.showInputDialog("Enter your height in inches"); height = Double.parseDouble(keyboard); BMI = ((weight*703)/(height*height)); if(BMI >= 18.5 && BMI <=30) JOptionPane.showMessageDialog(null, name + " BMI is " + BMI + " , The person has optimal weight "); else if (BMI < 18.5) JOptionPane.showMessageDialog(null, name + " BMI is " + BMI + " , The person is underweight "); else JOptionPane.showMessageDialog(null, name + " BMI is " + BMI + " , The person is Overweight "); System.exit(0); } }
Also is it possible to have the user input all the values in one page? instead of inputting weight then hitting ok then a new pop up for height comes up.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
