Java Reference
In-Depth Information
The following step enters code to call the finish() method as shown in
Figure 4-33.
To Enter Code for the finish() Method
1. Enter line 26 as shown in Figure 4-33.
The application now is complete. The following steps compile and run the
application, testing the application using sample data.
To Compile and Test the Application
OTHER WAYS
1. With the Data Disk in drive A, compile the program by clicking Compile
Java on the Tools menu. If TextPad notifies you of errors, click
Commission.java in the Selector window, fix the errors, and then
compile again. When the program compiles with no errors, click Run
Java Application on the Tools menu.
2. When the Input dialog box displays, type 52375 and then click the OK
button.
3. When the second Input dialog box displays, type 2 and then click the
OK button.
The Commission Totals dialog box displays the formatted sales and the
commission (Figure 4-34).
1. To compile, press
CTRL + 1
2. To compile at
command prompt,
type javac
Commission.java
3. To run, press CTRL + 2 ,
type 52375 , click OK
button, type 2 , click
OK button
4. To run at command
prompt, type java
Commission , type
52375 , click OK
button, type 2 , click
OK button
Commission
Totals dialog
box
formatted numeric
values display in
output message
OK button
FIGURE 4-34
4. Click the OK button in the Commission Totals dialog box. Click the
Close button in the command prompt window title bar.
The Commission program terminates and the command prompt window
closes.
The Commission class now contains six working methods: main(),
getSales(), getCode(), getComm(), output(), and finish(). You may want to print
a copy of the Commission.java source code for reference, as you modify the code
to create different versions of the program.
 
Search WWH ::




Custom Search