Java Reference
In-Depth Information
Sample Run: (Figure 5-2 shows the sample run.)
FIGURE 5-2 Sample run of TelephoneDigitProgram
The program in Example 5-5 works as follows: The statements in Lines 1 through 4 declare
theappropriatevariables.ThestatementinLine5createstheappropriatestringtobeincluded
in the input dialog box. The statement in Line 6 displays the input dialog box informing the
user what to do. This statement also retrieves the string entered by the user and assigns the
string to the object inputString . (Notice that even though the user enters a single letter, it is
still treated as a string.) The statement in Line 7 retrievestheletterfrom inputString and
stores it in letter .Theexpressioninthe while statement in Line 8 checks that the letter is
not # . If the letter entered by the user is not # , the body of the while loop executes. The
statement in Line 9 creates the appropriate string to be displayed in the output dialog box.
The if statement in Line 10 checks whether the letter entered by the user is uppercase.
If the letter entered by the user is uppercase, the logical expression in the if
 
Search WWH ::




Custom Search