Java Reference
In-Depth Information
To Compile the Source Code
1. With your Data Disk in drive A, click Tools on the menu bar. Click
Compile Java on the Tools menu.
TextPad compiles the program. If TextPad notifies you of compilation errors,
fix the errors in the BodyMass coding window and then compile the
program again.
OTHER WAYS
1. Press CTRL + 1
2. At command
prompt, type javac
BodyMass.java
Now that the program has been compiled into bytecode, you are ready to
execute, or run, the program and test the results of the coded calculations.
Running and Testing the Application
When you run an interactive Java program, such as the console application
version of the Body Mass Index Calculator, prompts will be displayed in the
command prompt window. The bytecode runs in the command prompt win-
dow, pausing every time the readLine() method is executed, to allow the user to
enter the data requested in the prompt. To test the program, programmers typi-
cally use the sample data that they created during program design and any sam-
ple data from the requirements document. During execution and testing, the
programmer acts as the user, entering data from a user's perspective as the
program runs.
The following steps execute and test the application.
To Run and Test the Application
1. If necessary, click BodyMass.java in the Selector window in TextPad.
Click Tools on the menu bar and then click Run Java Application on the
Tools menu. Type 67 in response to the first prompt.
The command prompt window displays the first prompt and user response
(Figure 3-21).
command
prompt
window
user inputs
first value
println()
method
causes text
to display
FIGURE 3-21
 
Search WWH ::




Custom Search