This is a computer science question i
The language is java.
Does anyone know how to write 3 test cases for a bmi method in a main method?
public class CalculateBMI { public static double bmi(double weightInPounds, double heightInInches) { return (weightInPounds * 703) / (heightInInches * heightInInches); } public static void main(String[] args) { double eps = 0.01; assert Math.abs(bmi(135, 72.3) - 18.155) < eps : "First case failed"; assert Math.abs(bmi(170, 75) - 21.246) < eps : "Second case failed"; assert Math.abs(bmi(190, 70) - 27.259) < eps : "Third case failed"; } }
Get Answers For Free
Most questions answered within 1 hours.