Prentice Hall Oracle Plsql By Example 3Rd Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Prentice Hall Oracle Plsql By Example 3Rd Edition [Electronic resources] - نسخه متنی

Benjamin Rosenzweig

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



Lab 1.2 Exercise Answers


This section gives you some suggested answers to the questions in Lab 1.2, with discussion related to how those answers resulted. The most important thing to realize is whether your answer works. You should figure out the implications of the answers here and what the effects are from any different answers you may come up with.

1.2.1 Answers


A1:

Answer: The technique of breaking a problem into parts and solving each part is called a top-down approach to problem solving. By breaking down the problem, it is easier to focus on possible solutions and manage each part. Once each part is fully understood, the solution to the overall problem can be readily developed.

A2:

Answer: Structured programming embodies a disciplined approach to writing clear code that is easy to understand, test, maintain, and modify. A program can be organized into modules called subroutines. These subroutines focus on a particular part of the overall problem that the program addresses. Subroutines are easier to understand and manage because they are only components of the overall program. Together, all of the subroutines compose the overall program.

A3:

Answer: Your selection structure should look similar to the following:

IF MONTH IN ('DECEMBER', 'JANUARY', 'FEBRUARY')

IT IS WINTER

IF MONTH IN ('MARCH', 'APRIL', 'MAY')

IT IS SPRING

IF MONTH IN ('JUNE', 'JULY', 'AUGUST')

IT IS SUMMER

IF MONTH IN ('SEPTEMBER', 'OCTOBER', 'NOVEMBER')

IT IS FALL

The test conditions of this selection structure use the operator IN. This operator allows you to construct the list of valid months for every season. It is important to understand the use of the parentheses. In this case, it is not done for the sake of a syntax rule. This use of parentheses allows us to define clearly the list of values for a specific month, hence helping us to outline the logic of the structure.

Now, consider the following fragment of the selection structure:

IF MONTH IS 'DECEMBER'

IT IS WINTER

IF MONTH IS 'JANUARY'

IT IS WINTER

IF MONTH IS 'FEBRUARY'

IT IS WINTER


This selection structure results in the same outcome, yet it is much longer. As a result it does not look well structured, even though it has been formatted properly.

A4:

Answer: Your selection structure should look similar to the following:

WHILE THERE ARE MORE DAYS IN THE WEEK

DISPLAY THE NAME OF THE CURRENT DAY

GO TO THE NEXT DAY

Assume that you are starting your week on Mondaythere are six days left. Next, you will display the name of the current day of the week, which is Monday for the first iteration. Then, you move to the next day. The next day is Tuesday, and there are five more days in the week. So, you will display the name of the current dayTuesdayand move to the next day, and so forth. Once the name of the seventh day (Sunday) has been displayed, the iteration structure has completed.

A5:

Answer: Your structure should look similar to the following:

WHILE THERE ARE MORE DAYS IN THE WEEK

IF DAY BETWEEN 'MONDAY' AND 'FRIDAY'

DISPLAY THE NAME OF THE CURRENT DAY

IF DAY IN ('SATURDAY', 'SUNDAY')

DISPLAY 'THE WEEKEND IS HERE, AND IT IS HERE TO STAY!!!'

GO TO THE NEXT DAY

This structure is a combination of two structures: iteration and selection. The iteration structure will repeat its steps for each day of the week. The selection structure will display the name of the current day or the message "The weekend is...."

Assume that you are starting your week on Monday again. There are six days left. Next, control of the flow is passed to the selection structure. Because the current day happens to be Monday, and it falls within the business week, its name is displayed. Then, control of the flow is passed back to the iteration structure, and you are ready to move to the next day.

The next day is Tuesday, and there are five more days in the week. So, control is passed to the iteration structure again. Tuesday also falls within the business week, so its name is displayed as well. Next, control is passed back to the iteration structure, and you go to the next day, and so forth. Once the day falls on the weekend, the message "The weekend is . . ." is displayed.

A1:

Answer: A well-formatted program is easier to understand and maintain because format can reveal the logical structure of the program.

A2:

Answer: First, the code of the program should be indented so that the logical structure of the program is clear. Second, the program should contain comments describing what is being accomplished.


    / 289