Previous Section
 < Free Open Study > 
Next Section

Answers to Selected Exercises

Chapter 1

Many of the questions in this chapter's exercise are "thought questions." The answers given here are typical or suggested responses, but they are not the only possible answers.

  1. Software engineering is a disciplined approach to the creation and maintenance of computer programs throughout their entire life cycle.

  2. (d) is correct. Although there is a general order to the activities, and in some cases it is desirable to finish one phase completely before beginning another, often the software phases overlap one another.

    1. When the program's requirements change; when a better solution is discovered in the middle of the design phase; when an error is discovered in the requirements because of the design effort.

    2. When the program is being debugged, because of compilation errors or errors in the design; when a better solution is found for a part of the program that was already implemented; or when any of the situations mentioned in part (a) occur.

    3. When there are errors that cause the program to crash or to produce wrong answers; or when any of the situations mentioned in parts (a) and (b) occur.

    4. When an error is discovered during the use of the program; when additional functions are added to an existing software system; when a program is being modified to use on another computer system; or when any of the situations mentioned in parts (a), (b), and (c) occur.

  1. Customer, bank card, ATM, PIN, account, account number, balance, display.

  2. This is a thought question; answers will vary for each student.

  3. The correction of errors early in the program's life cycle involves less rework. The correction can be incorporated into the program design. If detected late in the life cycle, errors may necessitate redesign, recoding, and/or retesting. The later the error is detected, the more rework one is likely to have to do to correct it.

  1. The body of the while loop is not in brackets.

    The comments include the call to Increment.

    The parameter to Increment is not a reference parameter.

  2. A single programmer could use the inspection process as a way to do a structured "deskcheck" of his or her program and would especially benefit from inspection checklists of errors to look for.

  3. a. It is appropriate to start planning a program's testing during the earliest phases of program development.

  4. Unit testing is the testing of a single unit of the program (for instance, a function). Integration testing is the testing of groups of already-tested units to make sure that they interact correctly and that the entire program works according to its specification.

  1. Top-down integration testing, using stubs, is performed to test the program in pieces, beginning with the top levels and continuing through the lower levels. Bottom-up integration testing, using test drivers, is used to test the lower-level program pieces independently of the higher levels of the program.

  2. Life-cycle verification refers to the idea that program verification activities can be performed throughout the program's life cycle, not just by testing the program after it is coded.

    1. num and denom are both just integer values. Each can be either negative or positive. In a fraction the numerator carries the sign. The denominator should always be positive.

    2. IsNotProper needs to be changed to use the absolute value of the numerator. Function Initialize (or any constructor) should check to be sure the denominator is strictly positive and throw an exception if this is not the case.

    3. The following tests need to be added to the test plan.

    Operation to Be Tested and Description of Action

    Input Values

    Expected Output


    -3, 4

    Numerator: -3

    Denominator: 4

    IsNotProper Initialize

    -13, 4

    Fraction is proper

    Numerator: -13

    Denominator: 4

    IsNotProper ConvertToProper


    Fraction is improper

    Whole number is 3

    Numerator is -1

    Denominator is 4

  1. ConvertToProper was not adequately tested. If the input results in a whole number and no fractional part, the fractional part is set to zero. The function should be tested with something like 8/4.

Previous Section
 < Free Open Study > 
Next Section
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)