6.1-6.5
6.1.1
P—|–Q–| ! ((P || Q) && (P && Q))
true|true | false
true|false| true
false|true| true
false|false| true
6.1.2
a. true
b. false
c. true
d. false
6.1.4
Grouping, Method Selector, Unary plus, Unary minus, Not, Multiplication, Division, Remainder or Modulus, Addition, Subtraction, And, Or, Assignment Operators.
6.1.5
if (x < p || x > q)
System.out.println(“reject”);
6.2.1
a.
numbers to test = 0, 1, -1
b.
numbers to test = -5, 10, 110
6.2.2
With complete code coverage, each line of code in the program is executed at least once, so everything gets tested.
6.2.3
everything that tests a program in the same way belongs to the same equivalence class, so testing two integers that are both accepted in the code, like testing 5 and 8 when the number must be between 1 and 100, would be considered an equivalence class.
6.2.4
boundary conditions are the boundaries between equivalence classes, so for testing the aforementioned numbers, it would be plugging in 0, 1, and 2.
6.2.5
Extreme conditions are the limits of the validity in the code, so to test them in this, they would be 0, and 100.
6.2.6
The tested equivalence classes would be between 0 and 60, and between 60 and 100.
The boundary conditions to test would be 59, 60, and 61.
The extreme conditions would be 0, 1, 99, and 100.
6.3.1
|Before Noon|Monday|___________Result_________|
|True______|True|____Take the computer science quiz|
|True______|False|_______________Go to gym class|
|False______|True|______Throw a Frisbee in the quad|
|False______|False|______Throw a Frisbee in the quad|
6.3.2
Nested if statements are programs that have multiple solutions which require the first if statement to be true in order to consider the second. Multiway statements do not require the first if to be true to consider the second.
6.4.1
if (income > 10000)
rate = 0.10;
else if (income > 20000)
rate = 0.18;
else if (income > 50000)
rate 0.40;
else
rate = 0.0
This code is written is such a way that anything above 10,000 would result in a rate of 10%. The code says that anything greater than 20,000 would be 18%, but that is only if 20,000 was less than 10,000, which is false.
6.4.2
if (income > 50000)
rate 0.40;
else if (income > 20000)
rate = 0.18;
else if (income > 10000)
rate = 0.10;
else
rate = 0.0
6.5.1
a.
1 2 3 1 2 3 1 2 3…
b.
1 2 3 1 2 3 1 2 3 …
6.5.2
for (int x = 1; x<=25; x++){
if(x % 5 == 0 ){
System.out.print(x);
System.out.println(” “);
}
System.out.print(x + ” “);
Loading...