Answer to Question #262461 in Java | JSP | JSF for Angel Silva

Question #262461

Create a class named MyClassCircle containing a parameterized constrictor of the class and a method name getArea(l that will calculate the area of the circle. Create another class names GetAreaDemo() that will contain the main method that will supply the arguments and display its output using the standard output stream.


1
Expert's answer
2021-11-07T15:54:50-0500
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());
  }
}

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