Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

Students also viewed these Databases questions

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago