Variables:

Method variables and parameters

 

A monkey calculates the hypotenuse given the length of two sides of a triangle.  The two lengths are given as input by the user.  Two versions are given of this animation: in the first, a monkey method is defined which uses variables in which to store the values input by the user and those calculated by the monkey; in the second, the monkey method takes two parameters (the lengths of the sides given as input in the main world method).

 

Demo 1                  Code

 

Demo 2                  Code