✏️ Explanatory Question
(vii)
John was asked to write a Java code to calculate the surface area of a cone. The following code was written by him:
Formula:
Surface area of a cone is A = πrℓ, where ℓ = √(r² + h²)
class area { double area(double r, double h) { double l, a; a = 22.0/7 * r * l; l = Math.sqrt(r * r + h * h); return a; } }
Task:
(a) Specify the type of error in the above program.
(b) Correct the program and write the error-free version.