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
You will be a hero!
Zigmanuir [339]

Answer: It's me again ;) The answer is 778,095

Step-by-step explanation: Find 90% of 864,550.

7 0
3 years ago
Read 2 more answers
Please answer quick!
elena-s [515]

Answer:

84

Step-by-step explanation:

3 times 4= 12

12 times 7= 84

6 0
4 years ago
What is 11/12 divided by 1/3 PLEASE HURRY
GuDViN [60]

Answer:

11/4 or 2 3/4

4 0
3 years ago
Alonzo runs 6 miles in 50 minutes. at the same rate, how many miles would he run in 35 minutes?
mihalych1998 [28]

Answer: 4.2 miles

Step-by-step explanation:

6 mi/50 minutes = 6/50 mi per minute

35 minutes * 6/50 = 4.2 miles

5 0
3 years ago
7) Which ordered pair is a solution of the equation 3y – 2 = 8x + 5? *
Ksenya-84 [330]
<span>If you plug in the values with their respective x and y variables you can find out.

For (1, 5): 
3y - 2 = 8x + 5
3(5) - 2 = 8(1) + 5
15 - 2 = 8 + 5
13 = 13

This is indeed correct because 13 equals 13.</span>
3 0
3 years ago
Other questions:
  • Consider the function f(x)=x^2+bx-49 where b is a constant. if the function has an axis of symmetry at x = 8, what is the value
    7·1 answer
  • A FedEx freight truck carries three tons of packages 660 miles on 90 gallons of diesel fuel from Miami, Fl to Atlanta, Ga. FedEx
    11·1 answer
  • pqrs is a rectangle with sides ps=5cm and pq =12cm find the length of qr ,sr and the two diagonals pr and qs. ​
    13·1 answer
  • Peter sells shoes. On Monday he sold 12
    5·1 answer
  • What is the slope of the line that passes through the points (0, -15) and (-16, -20)?​
    14·2 answers
  • If you need to put tile on your kitchen floor, do you need to know the perimeter or the area of the kitchen?
    9·2 answers
  • Find sin theta if cos theta is 4/5
    7·1 answer
  • The quality assurance engineer of a receiving-sets manufacturer inspects receiving-sets in lots of 50. He selects 4 of the 50 re
    11·1 answer
  • Find which of the following fractions is larger 51) 2/5 ,1/3, 1/15 = A) 2/5 B) 1/3 C) 1/15​
    7·1 answer
  • A carton of apples weighs 25.7 pounds. Michael orders 21 cartons. How much did all the cartons weigh?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!