Java Reference
In-Depth Information
PROBLEM ANALYSIS The Commission program should accept and test a
numeric value from the user, display a list of codes and test for a valid choice,
and then calculate and display results. The program also should include appro-
priate prompts and messages.
Because this program involves making decisions based on user input, the
code that executes each decision can be designed, developed, and tested individ-
ually as it is added to the program. Programmers commonly create a small por-
tion of code and then thoroughly test it before moving on to the next section.
The object-oriented nature of Java lends itself to this kind of component design,
creating reusable portions of code and breaking the programming tasks down
into simpler, more manageable steps. Throughout the chapter, the code for each
decision is designed and tested as it is added to the program.
DESIGN THE SOLUTION Once you have analyzed the problem, the next
step is to design the user interface and the logic to solve the problem. The
Commission program has two versions: a console application and an applet.
The console application uses dialog boxes with prompts and text boxes to accept
numeric input, and then displays formatted output in a message box, as shown
in the storyboard in Figure 4-3a. The applet uses a prompt, a text box, and
option buttons to accept input, and then displays formatted output in the applet
window, as shown in the storyboard in Figure 4-3b on the next page.
input prompt
text box for
input of sales
amount
Input dialog
boxes
text box for input
of single-digit
commission code
formatted output
message
box
FIGURE 4-3a
 
Search WWH ::




Custom Search