In this challenge you will design an algorithm to calculate the area of various shapes as listed below:
Shape | Name | Area |
Square | width^{2} | |
Rectangle | width x length | |
Circle | pi x radius^{2} | |
Triangle | base x height / 2 |
Your algorithm should:
- Ask the user which of the above four shapes they would like to calculate the area of,
- Based on the chosen shape, your algorithm should ask the end user to enter the required dimensions (e.g. width, or width and length or radius or base and height),
- Calculate and display the area of the chosen shape.
Flowchart Challenge
Use our flowchart desing tool to create the flowchart of your algorithm. Online Flowchart Creator
Python Challenge
Once you have completed your flowchart, you can implement this algorithm using Python code.
Test Plan
Test # | Input Values | Expected Output | Actual Output |
#1 | Square Width: 5 |
Area: 25 | |
#2 | Rectangle Width: 4 Length: 6 |
Area: 24 | |
#3 | Circle Radius: 10 |
Area: 314.159 | |
#4 | Triangle Base: 7 Height: 4 |
Area: 14 |
Extension Task
Complete your algorithm to cater for additional shapes including parallelograms, rhombus and hexagons.
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members Area