Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Important Notes Format the output using the sample output in the Example Output

ID: 3857261 • Letter: I

Question

Important Notes

Format the output using the sample output in the Example Output section as a guide

Design Document Requirements

UML Class Diagram (simply recreate the UML Class diagram provided at the end of the assignment)

Review the UML Class Diagramming page for assistance with working with UML Class diagrams

UMLet is a simple and easy tool for creating UML Class diagrams (download UMLet (Links to an external site.)Links to an external site.)

Project Requirements

Implement the Shape class defined in the provided UML Class diagram (located at the end of the assignment)

The Shape class must conform to the UML Class diagram provided

The Shape class must use the constructors, methods and variables provided

DO NOT modify the provided constructors, methods or variables

DO NOT create additional constructors, methods or variables

Shape Class ConstructorInitial the name and number of sides of the object instance

Assign the numSides parameter value to the numSides global variable

Determine the name based on the number of sides and assign the name to the name global variable

Circle = 1 side

Triangle = 3 sides

Rectangle = 4 sides

Polygon = 5 or more sides

Shape Class MethodscalcArea(double)

Calculate the area of a circle

calcArea(int)

Calculate the area of a polygon

calcArea(int, int)

Calculate the area of a rectangle

calcArea(int, int, int)

Calculate the area of a triangle

calcPerimeter(double)

Calculate the perimeter of a circle

calcPerimeter(int)

Calculate the perimeter of a polygon

calcPerimeter(int, int)

Calculate the perimeter of a rectangle

calcPerimeter(int, int, int)

Calculate the perimeter of a triangle

performCalculations Note: Each performCalculations method does the same thing.

Call the appropriate calcArea method and assign the result to the area global variable

Call the appropriate calcPerimeter method and assign the result to the perimeter global variable

toStringDisplay the information of the object instance

Display numeric values to 2 decimal places

Create a class for Project 3 (the class containing the main method)

Display name and the project title on separate lines, followed by a blank line

Create 4 Shape object instances for the following number of sides

1 - Circle

3 - Triangle

4 - Rectangle

8 - Polygon

Call the performCalculations method of each Shape object instance, and pass the appropriate data

Circle - radius = 6.28

Triangle - sideA = 3, sideB = 4, sideC = 5

Rectangle - length = 4, width = 7

Polygon - length = 5

Display the results of the program

Display the output header

Display the row dataCall the toString method of each Shape object instance

The toString method displays the information of a particular Shape object instance

Explanation / Answer

class Circle{
private int radius;
  
Circle(int radius){
this.radius = radius;
}
  
public double clacArea(int radius){
return 3.14 * radius * radius;
}
  
public double calcPerimeter(int radius){
return 2*3.14*radius;
}
  
public String toString(){
return "Radius of Circle is: "+this.radius+" Area of the Circle is: "+this.clacArea(radius)
+" Perimeter of Circle is: "+this.calcPerimeter(radius);
}
  
}

class Triangle{
private int sideA, sideB, sideC;
  
Triangle(int a, int b , int c){
this.sideA = a;
this.sideB = b;
this.sideC = c;
}

public double clacArea(int sideA, int sideB, int sideC){
return 0.5*sideB*sideC;
}
  
public double calcPerimeter(int sideA, int sideB, int sideC){
return sideA+sideB+sideC;
}
  
public String toString(){
return "Side of triangle are : "+this.sideA+" " +this.sideB+ "and "+this.sideC+" Area of the tirangle is: "+this.clacArea(sideA,sideB, sideC)
+" Perimeter of Triangle is: "+this.calcPerimeter(sideA, sideB, sideC);
}
  
}