Question
15 views
check_circle

star
star
star
star
star
1 Rating
Step 1

Programming instructions:

• Create a class shape and calculation to initialize objects and to perform calculations respectively.
• Create the required variables of shapes in it.
• Create methods to calculate the areas and perimeters of shapes.
Step 2

Program:

class Calculation    //create a class for calculation of shapes
{
void Rectangle(int x, int y)    //Create Rectangle() method to calculate the area and perimeter
{
System.out.println("Area of Rectangle: " + (x*y));  //Print the area of rectangle
System.out.println("Perimeter of Rectangle: " + 2*(x+y));   //Print the perimeter of rectangle
}
void Triangle(int x, int y, int z)  //Create Triangle() method to calculate the area and perimeter
{
System.out.println("Area of Triangle: " +(x*y)/2);  //Print the area of Triangle
System.out.println("Perimeter of Triangle: " + (x+y+z));    //Print the perimeter of Triangle
}
void Circle(double x)   //Create Circle() method to calculate the area and perimeter
{
System.out.println("Area of Circle: " + (3.14*x*x));    //Print the area of Circle
System.out.println("Perimeter of Circle: " + (2*3.14*x));   //Print the perimeter of Circle
}
}
public class Shapes     //Create a class shape to intializ...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Computer Science 