Challenge: Calculating Area
Let's calculate the area of a triangle by defining a class in this challenge.
We'll cover the following
Problem statement
Let’s start with a very basic example.
Write a package called Triangle
having two public
variables for length
and height
and one member method called area
which will return the area of the right angle triangle. You can calculate the area of a triangle using
Input
Two variables (integer or float) as the dimensions of the triangle.
Output
Area of that triangle.
Sample input
4, 5
Sample output
10
Coding challenge
Write your code below. It is recommended that you try solving the exercise yourself before viewing the solution.
Good Luck!
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy