[Java] Person.java

less than 1 minute read

class Person {
public static void printData(String name, int age, double height, double weight) {
System.out.println (“My name is” + name + “”);
System.out.println (“age is” + age + “age”);
System.out.println (“height is” + height + “m”);
System.out.println (“Weight is” + weight + “kg”);
double bmi = bmi(height, weight);
System.out.println (“BMI is” + Math.round (bmi) + “”);

if (isHealthy(bmi)) {  System.out.println ("standard value");
} else {  System.out.println ("Out of standard range");
}   }

public static String fullName(String firstName, String lastName) {
return firstName + “ “ + lastName;
}

public static String fullName(String firstName, String middleName, String lastName) {
return firstName + “ “ + middleName + “ “ + lastName;
}

public static double bmi(double height, double weight) {
return weight / height / height;
}

public static boolean isHealthy(double bmi) {
return bmi >= 18.5 && bmi < 25.0;
}
}

Tags:

Updated: