Area Calculator

In this project, we're going to make an application with which the user can quickly calculate the area (and perimeter) of the shapes we program. We will use functions! Functions are extremely important in all programming languages!


Play this demo in full screen.

1) Create a circle.


Play this demo in full screen.

2) Create a text sprite. This is where the answer to the calculation will be.


Play this demo in full screen.

3) Now, when a user clicks on the circle, ask the user to input a radius length and place the number that they input into the text sprite you created in Step 2.


Play this demo in full screen.

4) Create a function (see More Blocks in documentation) that returns the area of a circle given a radius of that circle. Use that function and the user input to calculate the area of the circle and put the result in the display window. Be sure that the math of your program returns the correct result.


Play this demo in full screen.

5) Use a JavaScript function to limit the result to 2 decimal points (search the internet to find a JavaScript function that does this).


Play this demo in full screen.

6) Replace the single number result with more descriptive text that still includes the correct answer.
Play this demo in full screen.

7) (challenge) If a user inputs a non-number, make your program ask the user for a number again or display an error.


Play this demo in full screen.

8) (challenge) Ask the user if they want to calculate the area or perimeter of the circle when they click on it. Change what your program does depending upon their answer.


Play this demo in full screen.

9) Add more shapes!


Play this demo in full screen.