PET Tutorial
Program Exploration Tool (PET) Tutorial
(These are the steps for running the PET application in the Cmput 101 lab environment)
-
Once the application is started, you should now see a screen that looks similar to this:
-
Copy the following into the Code window:
# asks the user for input; displays the input entered; # variable declaration int my_int define main { writeline "Good day!" write "Please enter an integer:" read my_int writeline writeline "You entered " my_int }
-
Click File > Save As…
You should already be in your home directory, but if needed, navigate to your home directory. (If you are in your home directory, in the drop down list beside 'Save In:' you should see a folder with the name of your login id.) Save this file as sample_1.txt -
Click the Run button to run the pseudocode entered, a prompt for the integer input should appear in the Terminal window. It'll look similar to the screenshot below (Note there are some errors in the code below. Ignore them. The code above is correct.)
-
Type an integer value in the input area beside the symbol :
$>
Press the Enter key.
-
You should now see the following output displayed in the Terminal window, and the value 5 stored in the variable, my_int.
Good day! Please enter an integer:<5> You entered 5
(This assumes 5 was entered, and Echo ON is chosen. Echo ON and OFF are not in the screenshots, but are available in the lab version of PET. Echo ON is the default, and reproduces in the Terminal output window what was input. In the above example, 5 was input. <5> was then reproduced in the Terminal output window.)