Shape Area Calculation Program
Requirements Specification
1. The program will continually display a menu to the user until the user chooses to quit. The menu choices are:
1. Calculate area of squares
2. Calculate area of rectangles
3. Calculate area of triangles
4. Calculate area of circles
5. Quit
2. If the user chooses to calculate the area of squares, an ‘area_of_squares’ method will ask for the following data which will be used to calculate and display the areas of the squares:
First square side length (L)
Number of further square areas to calculate (N)
Square size increment (I)
e.g. If the user enters L = 5, N = 3, I = 2 then three square areas of
L = 5, L = 7 and L = 9 will be calculated and displayed.
The formula for calculating the area of a square is:
Area = L * L
3. The other ‘areas’ types will be same except for the variables involved and the names of the methods:
Area of Rectangles
First rectangle length (L)
First rectangle height (H)
Number of further rectangle areas to calculate (N)
Size increment (I)
Formula is:
Area = L * H
Area of Triangles
First triangle base length (L)
First triangle height (H)
Number of further triangle areas to calculate (N)
Size increment (I)
Formula is:
Area = (L/2) * H
Area of Circles
First circle radius (R)
Number of further circle area to calculate (N)
Size increment (I)
Formula is:
Area = PI * R * R
Where PI = 3.1415927
4. If the user chooses to quit then they should be asked ‘if they are sure’ and if they are not, the program continues as previously described, otherwise the program terminates.
Data Analysis
Menu choices are Integers
All area variables are floating point numbers
User quit verification is a String
Bookmarks