Hello, I am doing a homework assignment for computer science in which I ask the user their height (in feet and inches) and weight, then I tell them their body mass index.
I'm having issues converting height into an easily computable form.
Right now I'm trying to split feet from inches and then change feet to inches and add it all together for the final calculation.
I'm using the String.split() method to try to break it apart but coming up with an error I seem unable to find any understandable help on.
The Error is:
BodyMassIndex.java:13: cannot find symbol
symbol : method split(java.lang.String,double,double)
location: class java.lang.Double
height.split("'", ft, inches);
^
1 error
(The arrow is pointing at the period incase it looks differently once posted.)
The following is my current code.
Code:
import java.util.Scanner;
import java.lang.String;
public class BodyMassIndex {
public static void main (String[] args) {
System.out.print("How many pounds do you weight? (lbs.)");
Scanner keyboard = new Scanner(System.in);
double weight = keyboard.nextDouble();
double ft = 0;
double inches = 0;
System.out.print("How many inches tall are you?");
Double height = keyboard.nextDouble();
Double.toString(height);
height.split("'", ft, inches);
double tinyinches = ft * 12 + inches;
double totalinches = tinyinches * tinyinches;
double prebmi = weight / totalinches;
double bmi = prebmi * 703;
String health = "zero";
if (bmi >= 30.0) {health = "Obese";}
if (bmi >= 25.0 && bmi <=29.9) {health = "Overweight";}
if (bmi >= 18.5 && bmi <=24.9) {health = "Normal";}
if (bmi <= 18.4) {health = "Underweight";}
System.out.printf("Your Body Mass Index is %.1f and you are %s", bmi, health);
}
}
Thank you for your help in advance.