The following program, VSPH, calculates the volume of a sphere. VSPH prompts for the radius of the sphere, then cubes it and multiplies by 4/3 π. VSPH executes INPUT to prompt for the radius. INPUT sets
Program: | Comments: |
|
|
« |
|
"Key in radius" | Specifies the prompt string. |
"" | Specifies the |
| In this case, the command line will be |
| empty. |
INPUT | Displays the prompt, puts the cursor at |
| the start of the command line, and |
| suspends the program for data input |
| (the radius of the sphere). |
OBJ→ | Converts the result string into its |
| component object — a real number. |
3 ^ | Cubes the radius. |
4 * 3 / π * →NUM | Completes the calculation. |
» |
|
|
|
`OVSPH ‰ | Stores the program in VSPH. |
|
|
Example:
Execute VSPH to calculate the volume of a sphere of radius 2.5.
J%VSPH%
Key in the radius and continue program execution. 2.5 `
RPL Programming