LAB211Assignment: Title Background Program Specifications

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Type: Short Assignment

Code: 762632981.docx

LAB211Assignment LOC:
Slot(s):
42
1

Title
Create a program to calculate perimeter and area.
Background
N/A
Program Specifications
Create a programto calculate the perimeter and the area of a Circle,a Rectangle and a Triangle.

Function details:

Function 1:Display GUI And Input Data.

 Users run the program. The program prompts users for the input Data.
 Auto next Function2.

Function 2: Perform function

 The program calculates the area and the perimeter of the input circle, the rectangle and the triangle
 Display the information on the screen and Exit the program.

Expectation of User interface:

1 2
=====Calculator Shape Program===== -----Rectangle-----
Please input side width of Rectangle: Width: 11.0
11 Length: 32.0
Please input length of Rectangle: Area: 352.0
32 Perimeter: 86.0
Please input radius of Circle: -----Circle-----
12 Radius: 12.0
Please input side A of Triangle: Area:452.3893421169302
5 Perimeter:75.39822368615503
Please input side B of Triangle: -----Triangle-----
5 Side A: 5.0
Please input side C of Triangle: Side B: 5.0
5 Side C: 5.0
Area:10.82
Perimeter:15.0

Guidelines
Student must implement the methods
- getPerimeter

- getArea

- printResult
in startup code.
Example:
- Createan abstract class Shape contains three methods printResult, getPerimeter and getArea.

- Create classes Triangle, Rectangle, Circle that extend from class Shape.

- Construct the shapesthat consists the properties of a circle (radius), a rectangle (width, length), a triangle (sideA,
sideB, sideC) and generate their getter and setter methods.

- Override the methods of the Shape class.

- Calculate the area of a circle using the formula Heron:

Use Math.sqrt()
- Calculate the area of a circle with Pi = Math.PI

Function 1: Calculate the perimeter


o Must create function: public double getPerimeter ()

 Return: the perimeter of the shape.

Function 2: Calculate the area.


o Must create function: public double getArea ()

 Return: The area of the shape.

Function 3: Display the shape information.


o Must create the function: public void printResult ()

 Return: void.

You might also like