Question: ( a ) All Paths Coverage and Control Flow Graphs. Specification A function, called freeDeliver, for an online food restaurant determines whether a customer gets

(a) All Paths Coverage and Control Flow Graphs. Specification A function, called freeDeliver, for an online food restaurant determines whether a customer gets a free delivery or not based on reward points to date and whether the customer is a local member or not.
Inputs
rewardPoints: accumulated reward points of a customer
localCustomer: true for a local customer; false otherwise
Outputs
CHARGE_DEL if rewardPoints =120 and !localCustomer
CHARGE_DEL if rewardPoints =80 and localCustomer
FREE_DEL if rewardPoints >120
FREE_DEL if rewardPoints >80 and localCustomer
INVALID if rewardPoints 1
Using the all paths coverage and control flow graphs technique, correctly connect the nodes given in the right-hand side of the above figure. To do so, use the code given in the left-hand side of the above figure. Keep the same order and place of each node, as shown above, in your answer sheet. Correctly answer the following questions to gain the marks.
I. What is (are) the next available node (or nodes) from Node (29)?
II. What is (are) the next available node (or nodes) from Node (35)?
III. What is (are) the next available node (or nodes) from Node (36..37)?
(B) I. What is the output on using the following values: rewardPoints =30, localCustomer = false?
II. What is the output on using the following values rewardPoints =20, localCustomer = true?
III. What is the output on using the following values rewardPoints =20, localCustomer = false?
(C) I. Path 1 is defined from Node (22..28) to Node (38..41). Indicate whether Path 1 is possible or impossible. If possible provide values for rewardPoints and localCustomer to reach your conclusion.
II. Path 2 is defined from Nodes (22..28)-(29)-(31)-(33..34)(35)-(38..41) Indicate whether Path 2 is possible or impossible. If possible provide values for rewardPoints and localCustomer to reach your conclusion.
public static Status freeDelivery
(long rewardPoints, boolean localCustomer)
{
Status rv = Status.INVALID;
long limit = localCustomer ?80 : 120;
long jumpLimit = localCustomer ?20 : 40;
if (rewardPoints >0){
if (rewardPoints jumpLimit)
rewardPoints -= limit;
if (rewardPoints > jumpLimit)
rewardPoints ==limit;
rewardPoints +=4*(jumpLimit);
if (rewardPoints > limit)
rv = Status.FREE_DEL;
else
rv = Status.CHARGE_DEL;
}
36..37
return rv;
}
( a ) All Paths Coverage and Control Flow Graphs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!