Question

This is a computer science question i The language is java. Does anyone know how to...

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?

Homework Answers

Answer #1
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";
    }
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Does anyone know how to calculate the expected cumulative relative frequency? I would appreciate you write...
Does anyone know how to calculate the expected cumulative relative frequency? I would appreciate you write the formula in here.
JAVA QUESTION I want to know how to combine different Shape objects in Java into one....
JAVA QUESTION I want to know how to combine different Shape objects in Java into one. For example, if I wanted to make a class called CoffeeCup, and it was supposed to be a to go coffee cup, how would I combine a Rectangle, and two Ellipses (on the top and bottom) and then use that as one object in a different class? Thank you in advance!
USING JAVA LANGUAGE : Using Doubly Linked List, create a java code that does the following...
USING JAVA LANGUAGE : Using Doubly Linked List, create a java code that does the following Without using LinkedList from the JAVA LIBRARY. and please include methods for each function. Create a menu that contains the following operations : 1. Add new node to DLL. ( as a METHOD ) 2. Delete a node from DLL. ( as a METHOD ) 3. Show how many nodes in DLL. ( as a METHOD ) 4. Print all data in the DLL....
Does anyone know how to use the GRETL software?
Does anyone know how to use the GRETL software?
MATLAB only. Computer science, do not change subject This is matlab question. Give me a working...
MATLAB only. Computer science, do not change subject This is matlab question. Give me a working code for cramers rule the function must accept and AUGMENTED matrix and then solve if the function you give will not accept augmented matrix i will badly dislike it Answer only correctly. take test cases to find output and match
Java program question! If I pass null to a method, how can I use the passed...
Java program question! If I pass null to a method, how can I use the passed value to compare. Here is example code, it might be wrong, please make it could run on eclipse. Public class hw{ public static void main (String args[]) { method1(); } private static void method1() { System.out.println(method(null)); } public static String method(int[] a) { return null; } What I want to get in the output is just "()". It is not just to type the...
I have a question relating to java in the IDE intelij: My professor wants us to...
I have a question relating to java in the IDE intelij: My professor wants us to make a sentiment analysis program in java. he gave us two java files but i do not know how to place them inside the IDE. these are the file names: MainApp.java ReviewClassifier.java how to i open them in the IDE? do i have to create a Project? how do i append them to it? I want to know the general idea of how to...
I need know how to Write a java program called character length that prompts the user...
I need know how to Write a java program called character length that prompts the user to enter a string and displays:x is the first character.) The length of the string is: xxxxx The strings first character is: x (where xxxxx is the length of the string and x is the first character.)
How do I find the size of the pointer datatype on my computer? I know how...
How do I find the size of the pointer datatype on my computer? I know how to get int, double, float, and char. But I have no clue how I would get this
Java Question 1. Create a POJO Class (Employee) with these properties: i. ID ii. Age iii....
Java Question 1. Create a POJO Class (Employee) with these properties: i. ID ii. Age iii. Name 2. Write the class to read into the memory. (Reader to read into the memory). 3. Write a Junit test for the Employee class.