Chapter 7 Exercise

EX 7-2
1.)The structure of a query-controlled loop that processes repeated sets of inputs is the String variable doInAgain. This variable controls how many times the loop repeats, initially, the variable equals “y”. As soon as the user enters a string other than “y” or “Y”, the program terminates.
2.)Since the input of a lower case letter and a capital case letter count two different input, the toLowerCase() method avoid the problem of entering a same letter with wrong and get the wrong result. Therefore, the toLowerCase facilitate the program by indiscriminate between the lower case and the capital case letter.

EX 7-3
1.)The role the menu plays is to display a list of options, after this, the user can select the one they needs.
2.)The menu-driven programs prompts fro additional inputs related to that option and performs the needed computations, after which it displays the menu again.

EX 7-4
1-a.)%11s
b.)%12s
c.)%-15
d.)System.out.printf(”%6o”, i)
e.)System.out.printf(%10.2f)
2-a.)10,000.50
b.)45 632
c.)34.54

EX 7-5
1.)The program will halt and give an error message.
2.)The programmer embeds the call to an input method in a try-catch statement, as its name implies, this statement consists of two parts. The statement within the try clause are executed until one of them throws an exception. If that happens, an exception object is created and sent immediately to the catch clause. The code within the catch clause is then executed. Alternatively, if no statement throws an exception within the try clause, the catch clause is skipped.

Advertisement
Published in: on January 8, 2008 at 1:49 pm  Leave a Comment  

The URI to TrackBack this entry is: http://nina19899.wordpress.com/2008/01/08/chapter-7-exercise/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.