LAB211Assignment: Title Background Program Specifications
LAB211Assignment: Title Background Program Specifications
LAB211Assignment: Title Background Program Specifications
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:
Users run the program. The program prompts users for the input Data.
Auto next Function2.
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.
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.
Use Math.sqrt()
- Calculate the area of a circle with Pi = Math.PI
Return: void.