Chapter 6.1~6.5

November 28, 2007 at 3:39 pm (Uncategorized)

6.1 1. (true true false true) (false true false true) (true false false true)2. Fill in the truth values in the following truth table:a.true b. false c.trued.false4. !> &&> //5. If ( min <= x && x<=max)System.out.println( “X is between the millennium and the maximum)6.2 1. a.If number greater than 0 that we do the work on action 1; if number smaller than 0 then we do the work on action 2. b. If number between 0 and 100, then we do the work on action 1; if number smaller than 0 and greater than 100, then we do the work on action 1. 2. That every line in a program is executed at least once. And this is not the same thing as testing all possible logical paths through a program, which would provide a more thorough test, but also might require considerably more test data. 3. They are equivalent from the perspective of testing the same paths through the program. For example if the employee type is 1, test data for he payroll program fall into just two equivalence classes: hours between 0 and 40 and hours greater than 4. It is near the boundaries between equivalence classes. And it si common for programs to fail at these points. For example, for the payroll program, this requirement means testing with hours equal to 39, 40 and 41. 5. It is with data at the limits of validity. For example, we choose hours worked equal to 0 and 168 hours. 6.6.31. A:the time is before noon B: the day is monday So A true and B true, than they will take the computer science quiz. And A true B false, than they will go to gym class. A false B true, than they will go to gym class. A false B false, than they will take the computer science quiz.2. What is the difference between a nested if statement and a multiway if statement ?Nested if statement provide one mechanism for dealing the complexity, and it offer an alternative. But Multiway statement is compared to the two-way and one-way if statements we have seen earlier.6 .41. Income need to change, which like: income > 20000 change to income > 20000 && income 50000.2. if (income > 10000)rate = 0.10;else if (income > 20000 && income 50000)rate = 0.40;elserate = 0.06.51.a)output will be 2, 3, run for three  times which 2,3 2, 3 2, 3 b.)out put will be 1,2,3 1, , 31, 2, 3 run for three times6.61.a) To test the number, we must test number that is bigger than 0, for example 1, 2,3. But it the number is smaller than 0, the test is wrong.b). Test the number that is bigger than 0 and smaller than 100, example, 1, 2, 3, 99, 98, 97. The number that is bigger than 100 or smaller than 0 will no be test number.2.3. When a loop that does not executes a fixed number of times, tis test data should be cover all tree possibilities. 4. A program that tolerates errors in user inputs and recovers gracefully is robust program.

Post a Comment