1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
r-ruslan [8.4K]
3 years ago
14

Write a function that takes the base and height of a triangle and return its area.

Mathematics
1 answer:
antoniya [11.8K]3 years ago
8 0
<h2><u>Answer:</u></h2>

<u></u>

    //Method/function name is areaOfTriangle

    //Return type is double

    //Method receives two parameters of type double - base and height

    public static double areaOfTriangle(double base, double height){

        //Find the area using the formula: 1/2 * base * height

        double area = 0.5 * base * height;

       

        //return the area

        return area;

       

   } //End of areaOfTriangle method

<h2><u>Step-by-step explanation:</u></h2>

<u></u>

The function above has been written in Java.

It contains comments explaining each line of the code. Please go through the comments.

In order to test the function, a complete program containing a main method has also been written. This is shown as follows;

//Class definition begins

public class Area{

       

    //Method/function name is areaOfTriangle

    //Return type is double

    //Method receives two parameters of type double - base and height

    public static double areaOfTriangle(double base, double height){

        //Find the area using the formula: 1/2 * base * height

        double area = 0.5 * base * height;

       

        //return the area

        return area;

       

    }  //End of areaOfTriangle method

   

   

    //Write the main method to call the method

    public static void main(String []args){

       

       //Call the areaOfTriangle() method in the main method

       //Set the base to 12 and the height to 6

       System.out.println(areaOfTriangle(12, 6));

    }

   

   

} //End of class definition

<h2><u>Sample Output</u></h2>

>> 36.0

You might be interested in
In apirl is rained 1/4 of a inch on 15 diffret day how many inches of rain fell
Ne4ueva [31]

In 15 diffret days 15/4 inches of rain fell in April month if every day rained 1/4 of a inch .

How to find the rain fell in 15 diffret days ?

We know that rain in every day is 1/4 of a inch

So for 15 days

1/4+1/4+1/4+......15times\\=15/4

So in 15 diffret days in April rain fell is 15/4 inches.

Learn more about the rain fall is here :

brainly.com/question/28049911

#SPJ4

8 0
2 years ago
Which ratio forms a proportion with 18/27 ?HELPPPPPP
harkovskaia [24]
 it would be the third one, 2/3
6 0
3 years ago
Read 2 more answers
Find the area of the parallelogram.<br> 22 mm<br> 11 mm
Zarrin [17]

Answer:

I have no idea

Step-by-step explanation:

6 0
3 years ago
Read 2 more answers
Find the value of x If necessary, you may learn what the markings on a figure indicate.
Igoryamba

Answer:

x=36°

Step-by-step explanation:

Find the answer with the theorems related to isosceles triangle and the exterior angle theorem

4 0
2 years ago
Which choices are equivalent to the expression below? Check all that apply square root -36
Mrac [35]
-6 or -3 if that is a choice.hope it hepls
7 0
3 years ago
Read 2 more answers
Other questions:
  • What are the possible values of x in 32x + 20 = 28x − 16x2?
    9·2 answers
  • you are going to buy doughnuts for your coworkers. you buy 2 boxes of glazed doughnuts for $3.99 each, 3 boxes of chocolate-cove
    8·2 answers
  • Help plz???? never learned this
    12·2 answers
  • There are 15 rolls of film in a box and 3 are defective. Two rolls are to be selected, one after the other. What is the probabil
    12·1 answer
  • What is M &lt; B?<br><br><br> Round the value to the nearest degree.
    8·1 answer
  • Brian was thinking of a number. Brian halves the number and gets an answer of 67.8. Form an equation with x from the information
    8·1 answer
  • 4(8x+6)-2=22<br> Please help​
    6·2 answers
  • Find the measure of each angle.
    10·2 answers
  • Chord AB is 3cm from the center of a circle, the radius of the circle is 5cm, calculate the length of the chord.​
    5·1 answer
  • I think it is A but i am not sure can someone check and tell me if im wrong
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!