Chapter 8, 8.6

1. Write the form of the markup tag for links.
text of link

2. What is an absolute path name? Give an example.
– It specifies the exact or absolute position of the file in the computer’s directory structure.
example: C:\Code\Java.html

3. What is a relative path name? Give an example.
– It specify the location of a target document relative to that of the currently displayed document.
example: /MyCode. html

4. Write the format of a URL to another Web site.
My e-mail

Chapter 8, 8.5

1. List three types of HTML lists and describe their characteristics.
— a. Unordered list: list items with bullets
b. Numbered list: list items with numbers
c. Definition list: list items with terms and definition.

2. Write an HTML code segment that uses a list to display the names of your grandparents and your parents. The list should be organized to show the relationships clearly:


  1. Grandparents

    • Grandma: Ming Ouyang
    • Grandpa: Shuyan Chen

  2. Parents:

    • Mother: Ling Lin
    • Father: Limin Chen

Chapter 8, 8.4

1. What happens if you forget to close the markup tag for italics on a piece of text?
— It will keep doing the italic for the whole thing.

2. What is the purpose of the escape sequences in HTML? Give an example.
— It will display the HTML special characters instead of using them.

Chapter 8, 8.3

1. When does the HTML programmer need to use forced line breaks?
— The programmer needs to put a
in the end of that line.

2. When do we use preformatted text in an HTML document?
— When we want the code reader to interpret the input from the keyboard.

3. Write an HTML code segment that shows a level 1 heading and a level 2 heading.

The first heading

First paragraph

The second heading


Second paragraph

Chapter 8, 8.2

1. What does HTML stand for?
— It stands for Hypertext markup language.

2. What is the purpose of HTML tags?
–It can indicate the format of texual elements or links to other nodes. It’s to tell the browser how it wants to be displayed.

3. Write an HTML code segment that shows the minimal HTML document structure for a Web page.

David Chen’s Page

David is handsome boy.

4. What is an HTML comment? Give an example.
–It is some lines that won’t appear on the screen and will make the code more readable.

Chapter 8, 8.1

1. describe the basic ideas underlying hypertext.
— A hypertext is a structure consisting of nodes and the likes between them.

2. Wha is the difference between hypertext and hypermedia?
–Hypermedia may show icon or image rather than as highlighted text.

3. What is a URL?
— Uniform resource locators. It’s the address of the website.

Chapter 7, 7.5

1. Assume that a program is trying to read a double value from the keyboard. The user enters the characters “$12.55″. Explain what happens next.
– The program will halt and give an error message.

2. Explain how a try-catch statement works.
– The try clause execut the statement that may throw exceptions. The clause will run until getting a exception, then the catch clause gets the exception and the statement within the catch clause is executed. If there is no exception, then the catch clause is skipped.

3. Write a code segment that loops until the user has entered a well-formed double value at the keyboard.
– 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);
}

Chapter 7, 7.4

1. write code segments to output the following formatted strings:
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)

2. Write the values returned by the following expressions (include spaces within the strings where relevant):
a. String.format(“%-10s%,10.2f”, “Price”, 10000.50)
–Price 10,000.50
b. String.format(“%6d%7d”, 45, 632)
— 45 632
c. String.format(“%5.2f”, 34.543)
–34.54

Chapter 7, 7.3

1. What role does a menu play in a program?
— A menu gives user various options to work on different jobs. The prompts for additional inputs related to that option and performs the needed computation only after user selecting an option from the menu.

2. Describe the structure of a menu-driven command loop.
— 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.

Chapter 7, 7.2

1. Describe the structure of a query-controlled loop that processes repeaed sets of inputs.
–The program ask the user a question of whether the program continue or not. With one input, the program will continue while with another one, the program will terminate.

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.

Newer entries » · « Older entries