Question: Given the following method: public class Calculator { / / Method to test with all def - use path criteria public static int calculateDiscount (

Given the following method:
public class Calculator {
// Method to test with all def-use path criteria
public static int calculateDiscount(int price, int customerYears, boolean isSpecialOffer){
int discount;
if (isSpecialoffer){
discount =20; // Special offer discount
} else {
discount =10;?? Base discount
}
if (customerYears >5){
discount +=5; // Loyalty bonus
}
int finalPrice = price price ** discount ?100;
if (finalPrice 0){
finalPrice =0; // Ensure final price is not negative
}
return finalPrice;
}
}
Complete the following tasks:
Draw a control flow graph for the lcs method.
Enumerate the nodes in the graph.
Label the control graph with defs and uses at the appropriate nodes.
 Given the following method: public class Calculator { // Method to

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 Databases Questions!