First time using classes --- The method is undefined
807605Oct 11 2007 — edited Oct 11 2007These are my two programs.
The error I pointed out in my main program is saying getBMI is undefined and I do not how to define it, or fix it. Please help
import java.util.Scanner;
import java.lang.Math;
public class ClientBMI
{
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
ClientBMI c1 = new ClientBMI();
//Client1
System.out.println ("Please enter last name of first client:");
String name1 = in.next();
System.out.println ("Please enter the age first client:");
String age1 = in.next();
System.out.println ("Please enter the height of first client:");
double height1 = in.nextDouble();
System.out.println ("Please enter the weight of first client:");
double weight1 = in.nextDouble();
System.out.println ("It is " + getBMI()); <---has the error Method is undefined
******************************************************************************************************************
no errors in my class file though
import java.lang.Math;
public class ClientBMIclass
{
public double height1;
public double weight1;
public int bmi;
//Create Constructor
public ClientBMIclass()
{
}
public double getBMI()
{
double bmi = (weight1 * 703) / (Math.sqrt (height1 * 12));
return bmi;
}
}
}
}
Edited by: Energybolt_00 on Oct 11, 2007 3:05 PM
Edited by: Energybolt_00 on Oct 11, 2007 3:06 PM
Edited by: Energybolt_00 on Oct 11, 2007 3:07 PM
Edited by: Energybolt_00 on Oct 11, 2007 3:11 PM