Engineering

Computer ScienceQ&A Library7:29A online.claflin.eduCSCI 206 LabLab 4 - Calculating ShapesDate: 7 February 2020Due: 13 February 2020Please submit your lab on Moodle.Notes:Make sure to use variable names that make sense.Add comments to document your code. Comments are not optional and must be included.Use a one-line comment before each block to describe what you are doing – don't describe thecode syntax, but rather the purpose of the code. These comments should effectively describethe steps in your "algorithm."Spell things carefully, including capitalization, since Java is fussy about thatIndent things carefullyCheck your results! Testing your code is IMPORTANT!Create a program to calculate the perimeter and area of the following shapes.4121RightAngler = 111540Use the numbers on the sides of the shapes for your calculations.Add comments to document your code. Comments are not optional and must be included.Your output is up to you. It should be easy to read and understand and you can format it any way youlike.The output should state the following information:The perimeter of the rectangle.The area of the rectangle.o The perimeter of the triangle.The area of the triangle.The perimeter of the circle.The area of the circle.Page 1 of 1Question

Asked Feb 14, 2020

15 views

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...

Tagged in

Find answers to questions asked by student like you

Show more Q&A

Q: 9. Implement an array with values 1, 5, 14, 23, 45, 52, 58, 81, 82 91. a) Create a getindex( functio...

A: Solving the given problem by using C++, as no programming language is specified. The below given C...

Q: You have been asked to assess the success of a recently implemented system that has been deployed ac...

A: The Supply chain information system manages and helps in determining the supplies that are needed fo...

Q: Describe the bull’s-eye model. What does it say about policy in the information securityprogram? Dis...

A: Click to see the answer

Q: :Normalization Topic What is BCNF? Please, give example.

A: 3NF: It is used to normalize a database (reduce redundancy and dependency). Larger tables are divide...

Q: Can you help me solve this and explain it step by step on how the answer was found please. Given int...

A: The function at(i) returns the reference of the element at position i in the vector. Hence, if the v...

Q: Create a complex query based on two or more tables (SCHOOL, DEPARTMENT, PROFESSOR, TECHNOLOGY, COURS...

A: Query:SELECT DEPARTMENT.DEPARTMENT_NAME, DEPARTMENT.DEPARTMENT_ID,SCHOOL.SCHOOL_CODE,COURSE.COURSE_T...

Q: Convert the following: 40 base 8 to base 7 34 base 6 to base 3

A: Click to see the answer

Q: TestCircle• Create a Circle with the radius• Print the radius using the getters• Print the Circle’s ...

A: The given criteria is written in Java programming language.

Q: In java Define and create an array of 10 integers. The array elements should be initialized to zero.

A: Array in java: An array is a set of like-typed variables, to which a common name refers. Java array...