Challenge 1: Calculating the Area
In this challenge, you will implement a class for calculating the area of the right angled triangle.
We'll cover the following
Problem statement
Basic maths is something we all learned in our early years. Areas of shapes, their perimeters and so on! Today, we want you to calculate the area of the right-angled triangle using a class.
Coding exercise
Write a class having two double
type variables for length
and height
, an overloaded constructor and one member function called area
which will return the area of the right-angled triangle.
Only write the code where instructed in the snippet below.
Test your code against our cases and see if you can pass them.
The solution is given in case you get stuck and the next lesson will include a review of the solution, but it is highly recommended that you try it yourself first!
Good Luck!
Get hands-on with 1400+ tech skills courses.