0

Why won't this printf statement work with a method call? I would like to format the roundoff errors from the BMI math calculation.

System.out.printf("Your BMI is: %10.2f\n", calcBMI(user_AGE,user_WEIGHT,user_HEIGHT));


    public static double calcBMI(int age, double weight, double height){
//        Calculate BMI by dividing weight in pounds (lbs) by height in inches (in)
//          squared and multiplying by a conversion factor of 703.
//        BMI formula: weight (lb) / [height (in)]2 x 703

//        preconditions: ****
        double BMI = weight / Math.pow( height,2)*703;
        return BMI;
    }
phillipsK
  • 1,466
  • 5
  • 29
  • 43

1 Answers1

0

I have tried the exact same code you have and it worked fine without errors. Hence I suppose it could be a Compiler Compliance issue. Please try this link and see how it goes. Basically it is about setting your compiler compliance level above 16.

Community
  • 1
  • 1
Joel Min
  • 3,387
  • 3
  • 19
  • 38