Java Reference
In-Depth Information
Debugging Assignment
Start TextPad and open the file, Bert, from the Chapter03 folder on the Data
Disk. See the preface of this topic for instructions for downloading the Data
Disk or see your instructor for information about accessing the files required in
this topic.
The Bert program is a Java application that calculates the monthly payment
on a car by requesting inputs from the user, performing calculations, and dis-
playing output, as shown in Figure 3-55.
FIGURE 3-55
The Bert program has several syntax, semantic, and logic errors in the
program code. Perform the following steps to debug the program.
1. Open the file Bert.java in TextPad.
2. Insert your name as the programmer in line 3 of the comment header. Insert
the current date in line 4 and write a purpose comment for the program in
line 6. Read through the code and fix any errors that you see.
3. Compile the program. As TextPad displays compilation errors, return to the
coding window to find the first error, fix it, and then recompile the program.
4. When you have fixed all the syntax and semantic errors so that the program
will compile without errors, run the program. Use the following sample data
in Table 3-18 to test the program for run-time and logic errors. Fix any
errors and compile again.
Table 3-18
Sample Data for Bert Program
Name
Christy Minton
Price
17,500
Down payment
500
Trade-in value
1250
Number of months of loan
60
Decimal interest value
.05
5. When the program compiles and runs to produce the output as shown in
Figure 3-55, print a copy of the source code.
 
Search WWH ::




Custom Search