Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AreaCalculator {
- public double radius = 2.0;
- public double length = 4.0;
- public double width = 6.0;
- public double height = 5.0;
- public double base = 3.0;
- public double getAreaCircle(double radius) {
- this.radius = radius;
- double areaCircle = radius * radius * Math.PI;
- System.out.println("Area of the Circle: " + areaCircle + "m^2\n");
- return areaCircle;
- }
- public double getAreaTriangle(double length, double width) {
- this.length = length;
- this.width = width;
- double areaTriangle = (length * width) / 2;
- System.out.println("Area of the Triangle: " + areaTriangle + "m^2\n");
- return areaTriangle;
- }
- public double getAreaQuadrilateral(double height, double base) {
- this.height = height;
- this.base = base;
- double areaQuadrilateral = height * base;
- System.out.println("Area of the Quadrilateral: " + areaQuadrilateral + "m^2\n");
- return areaQuadrilateral;
- }
- public double getAreaCylinder(double radius, double height) {
- this.radius = radius;
- this.height = height;
- double areaCylinder = 2 * Math.PI * radius * (radius + height);
- System.out.println("Area of the Cylinder: " + areaCylinder + "m^2\n");
- return areaCylinder;
- }
- public static void main(String[] args) {
- AreaCalculator areaCalc = new AreaCalculator();
- getAreaCircle(double radius);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement