100) { invalidEntry(); die(); } else { // form html page and table print("" ); print("" ); print("" ); print("" ); print("" ); print( "" ); // switch to determine which loop is used switch($Form_TYPE) { case "whileLoop": $num = 1; while ($num<=$Form_NUMBER) { $numarray[$num][0] = $num; $numarray[$num][1] = square($num); $numarray[$num][2] = cube($num); $num++; } break; case "doLoop": $num = 1; do { $numarray[$num][0] = $num; $numarray[$num][1] = square($num); $numarray[$num][2] = cube($num); $num++; } while ($num<=$Form_NUMBER); break; case "forLoop": for ( $num = 1; $num <= $Form_NUMBER; $num++ ) { $numarray[$num][0] = $num; $numarray[$num][1] = square($num); $numarray[$num][2] = cube($num); } } for ($n = 1; $n <=$Form_NUMBER ; $n++) { print( ""); print("" ); print( ""); } print( "
Squares and Cubes
Original NumberSquaresCubes
" . $numarray[$n][0] . "" . $numarray[$n][1] . "" . $numarray[$n][2] . "

" ); } //calculate the square function square($x) { return $x * $x; } //calculate the cube function cube($x) { return $x * $x * $x; } //print Error if a number between 1 & 100 is not entered function invalidEntry() { print( " ERROR Invalid number entered. Please enter a number between 1 and 100. Try Again
" ); } //print Error if a field is left blank function fieldsBlank() { print( " ERROR Please fill in all form fields. Try Again
" ); } ?>