This week’s assignment deals with procedures. Once a procedure is defined and coded it is placed in a custom block to allow a call of that procedure by inserting a block with that name into your other code. This reduces clutter in the main body of the program. It is also useful in teaching the used of called routines or functions in languages like C+, Ruby and Java.
We were to choose two problems from the book, find a solution to the problem then modify that code and possibly make it more useful.
For the first problem I chose problem 3. This is to created a procedure for converting °C to °F only. The procedure may be seen <HERE>.
The modifications I made were to make a calculator that converts both ways as shown below.
You make click the screenshot to see the code changes and use the converter.
Problem 5: Create a procedure to calculate the area of a circle based upon the radius. The procedure may be found <HERE>
My modifications to this were to make the calculator more useful by allowing the user to also calculate the circumference of a circle simply by selecting C for circumference or A for area. Click on the screenshot below to go to the calculator.