Answer to Question #263751 in Java | JSP | JSF for Matteo Villamor

Question #263751

class MyClassCircle {

private double radius;

MyClassCircle(double radius) {

this.radius = radius;

}

public double getArea() {

return Math.PI * radius * radius;

}

}


class GetAreaDemo {

public static void main(String [] args) {

MyClassCircle circle = new MyClassCircle(5.6);

System.out.println("Area of the circle with radius 5.6 equal to " + cicle.getArea());

}

}


What is the use/uses of variable, double radius and MyClassCircle in the program?


1
Expert's answer
2021-11-10T00:44:39-0500

SOLUTION TO THE ABOVE QUESTION


ANSWER.


I)The variable radius is an attribute of the entity circle which stores a value used to calculate the area of the circle using the formula area = PI*radius*radius


II)The variable MyClassCircle is a class name which is used to create an object circle which is used to perform all operations related to the object circle like calculating its area by invoking the method getArea() i.e. (circle.getArea())



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS