Advertisement
Guest User

khete kha

a guest
Mar 31st, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. public class AreaCalculator {
  2. public double radius = 2.0;
  3. public double length = 4.0;
  4. public double width = 6.0;
  5. public double height = 5.0;
  6. public double base = 3.0;
  7. public double getAreaCircle(double radius) {
  8. this.radius = radius;
  9. double areaCircle = radius * radius * Math.PI;
  10. System.out.println("Area of the Circle: " + areaCircle + "m^2\n");
  11. return areaCircle;
  12. }
  13. public double getAreaTriangle(double length, double width) {
  14. this.length = length;
  15. this.width = width;
  16. double areaTriangle = (length * width) / 2;
  17. System.out.println("Area of the Triangle: " + areaTriangle + "m^2\n");
  18. return areaTriangle;
  19. }
  20. public double getAreaQuadrilateral(double height, double base) {
  21. this.height = height;
  22. this.base = base;
  23. double areaQuadrilateral = height * base;
  24. System.out.println("Area of the Quadrilateral: " + areaQuadrilateral + "m^2\n");
  25. return areaQuadrilateral;
  26. }
  27. public double getAreaCylinder(double radius, double height) {
  28. this.radius = radius;
  29. this.height = height;
  30. double areaCylinder = 2 * Math.PI * radius * (radius + height);
  31. System.out.println("Area of the Cylinder: " + areaCylinder + "m^2\n");
  32. return areaCylinder;
  33. }
  34. public static void main(String[] args) {
  35. AreaCalculator areaCalc = new AreaCalculator();
  36. getAreaCircle(double radius);
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement