Archive for January, 2008




Chapter 8

8.11) A hypertext is a structure consisting of nodes and the links between them. Each node is a document or chunk of text. Normally, links to other nodes are displayed  to the user as embedded, highlighted terms within  a given chunk of text. The user moves to the node by using an arrow key or mouse o select an associated term.2) Hypermedia is like hypertext, but adds GUI, Images,Sound, Animation,andApplication 3)URL is the address on the page for the World Wide Web8.21. HTML stand for Hypertext markup language2. The HTML text can indicate the format of textual elements or links to other nodes.3.<HTML>   <HEAD>    <TITLE> the title goes here </TITLE>     </HEAD>      </BODY>       </HTML> 4.HTML is a comment for the creator to review.It is information that only the creator could see and the browser does not interpret or show i to the reader8.31. The HTML programmer need to use forced line break because a web page author or designer wants to display several lines of test without word trap.2.We use preformatted text in an HTML document when we want the browser to display text, with line breaks, extra spaces, and tabs.8.41. If you forget to close  the markup tag for italics on a piece of text everything after the first quote will be italics.2. The purpose of the escape sequence in HTML is to let the browser to display these characters rather than interpret them.8.51. the three types of HTML are:Unordered (bulleted) lists a bulleted list Numbered (ordered) can be nested within other lists to any depth,but more than three levels deep can be difficult  to readDefinition( association) displays terms and their associated definition2. 8.6  1. text in  the link 2. An absolute path name because it sepcifies the exact or absolute position of the file in the computer’s directory structure. 3. We can use absolute or relative path names to specify the location of a target document.4.8.71. An inline images are graphical images that are displayed when the user opens a page. External images are not displays until the user click on a link.2. The from of the markup tag for an inline image is <IMG src=” ImageLocation”> 3. <IMG src=”mypicture.gif” HEIGHT=200 WIDTH=2004. Two ways of tagging an external image<A href=”mypicture.gif”>Sample picture</A><A href=”mypicture.gif”><IMG src=”mythumbnail.gif”></A8.9 1. An HTML document that contains an applet markup tag and a byte code file for the applet-That is, a compiled Java applet in a .class file 2. 2.)Applications that use a specialized view class for the main window, the conversion to an applet is surprisingly simple. First, replace the name JFrame with the name JApplet at the begining of the class definition. Second, replace the class’s constructor by the method init: public void init(){ } 3.)An applet cannot access files on the ensure security on the user’s machine. 4.)The images must reside on the Web server from which the applet’s byte code was sent. The JApplet method getDocumentBase() locates and returns the URLof the applet’s Web server. The JApplet method getImage expects this URL and the filename of an image as parameters. The method downloads the image from the Web server and returns an object of the class Image. This object can be converted to an ImageIcon object for further processing by using the ImageIcon(anImage) constructor.                                                                                                

Add comment January 25, 2008

Chapter 7

7.21. The key to this pseudocode is the String variable doItAgain. 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.Browse into the String class in Sun’s Java API documentation. Expain how the method toLowerCase could be used to simplify the loop control condition of the query-driven loop in the example program.–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 letter and the capital case letter.

 

7.31. The role that the menu plays is to display a list of options. so that the user can select the one that he or she needs.2. The loop first display a range of options to choose from. After choosing a direction, the program then proceed into a loop. After the loop run through, it display another menu that user can choose whether to stay in that loop or to terminate it. In some program, there may be multiple loops. 3. Public class Various toppings {Public static void main (String [ ] args) {  Scanner reader = new Scanner (System.in); String menu; int menu Option; menu = “\n1)mushrooms “                      + ”\n2) peppers”              +”\n3) sausages”             +”\n4) Quit”            +”\Enter your option of the toppings you want: “;menu option = 5;while (menu Option ! = 4){      system.out.print(menu);      menuOption = reader. nextInt ();     System.out.println(” “);if (menuOption == 1){System.out.println(“Mushroom “);}else if (menuOption ==2)System.out.println(“peppers”);}else if (menuOption == 3)System.out.println(“sausage”);}else if ( menu Option ==4)System.print ln(“Goodbye! “);elseSystem.out.println(“Invalid Option”);    7.4 1. a.” One space” “%11s”b.” Two spaces” “%12s”c.”Three spaces ” “%-15″d.The value of int variable i, right-justified in a field of six columns: System.out.printf(”%6o”, i)e.The value of double variable d, right-justified in a field of 10 columns with a precision of 2: System.out.printf(%10.2f) 2a. String.format(”%-10s%,10.2f”, “Price”, 10000.50)Price 10,000.50b. String.format(”%6d%7d”, 45, 632) 45 632c. String.format(”%5.2f”, 34.543)34.547.51.The program will halt and give an error message.   2. The programmer embeds the call to an input method in a try-catch statement. The statements within the try clause are executed until one of them throws an exception.Alternatively, If no statements throws an exception.If that happens, an exception object is created and sent immediately to the catch clause. the code within the the try clause, the catch clause is skipped. 3.Double x;while (continue.equals(”y”)|| continue.equals(”Y”)){while (true)try{System.out.print(”Enter a well-formed double value: “);x= reader.nextDouble();break;}catch(Exception e){System.out.println(”Error in number format!”);reader.nextLine();}System.out.println(x);}

Add comment January 8, 2008

Pages

Categories

Links

Meta

Calendar

January 2008
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

Posts by Month

Posts by Category