Worksheet 1- functions
Worksheet 1- Functions
You require a program that prompts the user for the length and width of a rectangle and the radius of a circle. The program should calculate and display the perimeter and area of the rectangle and the circumference of the circle. Write a defining diagram and pseudocode for this problem.
A. Defining Diagram
| Input |Processing |Output |
| | Prompt and Read length, width, radius | |
|length |Calculate perimeter |perimeter |
|width |Calculate area |area |
|radius |Calculate circumference |circumference |
Solution Algorithm (pseudocode)
Function Main
Prompt for length, width, radius
Read length, width, radius
perimeter = 2*length + 2*width
area = length * width
display perimeter and area
circumference = 2*Pi*r
display circumference
End
B. Solution Algorithm with separate functions to calculate perimeter, area and circumference
Function Main
Prompt for length, width, radius
Read length, width, radius
perimeter = Call Calc_Perim(length, width)
area = Call Calc_Area(length, width)
display perimeter and area
circumference = Call Calc_Circ(radius)
display circumference
End
Function Calc_Perim(l, w)
return l * w;
End
Function Calc_Area (l, w)
A = 2 * l + 2 * w;
return A
End
Function Calc_Circ(r)
C = 2*Pi*r
return C
End
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- significant figures worksheet 1 answers
- worksheet piecewise functions answer key
- exponential equations worksheet 1 answers
- metric conversions worksheet 1 answers
- number tracing worksheet 1 10
- characterization worksheet 1 key
- vector addition worksheet 1 answers
- algebra 1 functions review worksheet
- algebra properties worksheet 1 27
- proofs worksheet 1 answer key
- types of conflict worksheet 1 answer key
- 941 worksheet 1 2020