Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Derive a set of basis paths that can be used to test the program (iv) Given that

ID: 3866199 • Letter: D

Question

Derive a set of basis paths that can be used to test the program
(iv) Given that the baseRate is $500.00, create the test cases that will exercise all the branches for switch case C4 only. The test cases should show the inputs, the path taken and the expected output. [Hint: There should be only two test cases.]

anybody know these two questions for the following code.(the answer posted before is wrong )..

program compute_insurance_premium() 2 integer driverAge, points 3 real baseRate, premium 4 Input(baseRate, driverAge, points) 5 safeDriveFactor = 0.0 6 premium = 0.0 7 switch (driverAge) { 8 case C1: 16 <= driverAge < 25 9 ageFactor = 3.0 10 if points < 2 then 11 safeDriverFactor = 40 12 end if 13 break; // End Case – C1 14 case C2: 25 <= driverAge < 45 15 ageFactor = 2.2 16 if points < 3 then 17 safeDriverFactor = 40 18 end if 19 break; // End Case – C2 20 case C3: 45 <= driverAge < 65 21 ageFactor = 1.5 22 if points < 5 then 23 safeDriverFactor = 80 24 end if 25 break; // End Case – C3 26 case C4: 65 <= driverAge < 100 27 ageFactor = 2.0 28 if points < 2 then 29 safeDriverFactor = 120 30 end if 31 break; // End Case – C4 32 default: 33 Output("Driver age out of range.") 34 } //End switch 35 premium = baseRate * ageFactor - safeDriverFactor 36 Output(premium)

Explanation / Answer

Set of basis paths:
The main gist of the problem is taking the inputs of base rate,
driver age, points of a person and calculate his/her insurance premium.

Test Case:1
baseRate driverAge points

500.00 65 1

Explaination:
By giving this input the program control goes to the case C4. The driverAge is between 65 to 100. ageFactor = 2 is assigned. For the if statement input number for the points is 1 which is less than 2 and satisfies the if statement, so safeDriverFactor = 120 is assigned. End of the if and breaks. Now premium = 500 * 2 - 120 = 880. 880 is the output which is printed.

Test Case:1
baseRate driverAge points

500.00 90 5

Explaination:
Initial value of safeDriverFactor = 0
By giving this input the program control goes to the case C4. The driverAge is between 65 to 100. ageFactor = 2 is assigned. For the if statement input number for the points is 5 which is greater than 2 and it does not satisfy the if statement, so safeDriverFactor = 0 is remains the same. End of the if and breaks. Now premium = 500 * 2 - 0 = 1000. 1000 is the output which is printed.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote