Question: 2. (4 points) Fill in the blanks below to create a static method that takes as parameters two integers representing the base b and height

 2. (4 points) Fill in the blanks below to create a

2. (4 points) Fill in the blanks below to create a static method that takes as parameters two integers representing the base b and height h of a triangle and computes and returns the area of the triangle as a real number (i.e., one that could have a fractional part). (Recall: The area of a triangle is the product of its base and height, divided by 2.) triArea(- _) { public double area = } For example: the method call triArea(3, 6) should return 9.0 the method call triArea(7, 5) should return 17.5 Note that the body of the method should be exactly two lines: one line that assigns the appropriate expression for the area to to the variable area, and a second line that returns the value of area. Important: In Java, the / operator is used for both integer division and floating-point division. In order to get floating-point division which preserves the digits after the decimal you need to make sure that at least one of the operands is a floating-point number. If both of the operators are integers, you will get integer division

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!