Java Reference
In-Depth Information
2 Analysis and Design (continued)
3. Validate the design. Have a classmate or your instructor look over your
storyboard and make suggestions before you proceed.
4. Implement the design. Translate the design into code for the applet. Create
an HTML document to host the applet.
5. Test the solution. Test the program, finding and correcting errors (debug-
ging) until it is error-free.
6. Document the solution. Print a copy of the source code, the HTML code,
and a copy of the applet interface.
7. Hand in all documents to your instructor.
3 Coding Your Own Splash Screen
In order to practice writing, compiling, and running Java, you decide to create a
Java application that displays your name and address on the screen. Perform the
following steps.
1. Start TextPad. Save the file on the Data Disk with your first name as the file
name. Make sure you choose Java (*.java) in the Save as type box. Click the
Save in box arrow to save the file on drive A in the folder named Chapter02.
2. Type the block comments to include your name, the date, the program's
name, the course number, and the program's purpose. Press the TA B key as
needed to align the comments. Remember to use /* to begin the block com-
ment and */ to end it.
3. Type the class header. Use your first name as the name of the class. Do not
forget to enter the keywords, public and class, before your name. On the next
line, type an opening brace.
4. Type the main() method header, using the keywords public, static, and void.
The main() method takes a String[] parameter named args. As you type,
remember that Java is case-sensitive. On the next line, type an opening
brace.
5. Type three lines that begin System.out.println(“ and then include your
name, address and city each on a separate line. Do not forget to close the
quotation mark and parentheses. Place a semicolon at the end of each line.
6. Type a closing brace for the main() method.
7. Type a closing brace for the class.
8. Compile the program by clicking Compile Java on the TextPad Tools menu.
If necessary, fix any errors in the coding window and then compile the pro-
gram again.
9. Once the program compiles correctly, run the program by clicking Run Java
Application on the TextPad Tools menu. After viewing your output, click the
Close button in the command prompt window title bar.
10. In the TextPad window, use the Print command on the File menu to print a
copy of the source code.
11. Close the TextPad window.
Search WWH ::




Custom Search