Question: package sample;import java.util.Scanner;public class CostCalculator { public static void main ( String args [ ] ) { System.out.print ( Please enter the number of

package sample;import java.util.Scanner;public class CostCalculator { public static void main(String args[]){ System.out.print("Please enter the number of A items: "); Scanner s = new Scanner(System.in); int num_A = s.nextInt(); System.out.print("Please enter the number of B items: "); int num_B = s.nextInt(); System.out.println("Total cost with shipping: "+ total_cost_with_shipping(num_A,num_B)); } public static int total_cost_with_shipping(int num_A, int num_B){ int tot_cost=0; if(num_A <0) return -1; if(num_B <0) return -1; if(num_A + num_B ==0) return -1; tot_cost += num_A *40; tot_cost += num_B *70; if(tot_cost <200)
tot_cost +=10; return tot_cost; }}
a. Draw a control flow graph for the program and clearly label each node to show its correspondence to a statement
.b. Calculate the programs cyclomatic complexity. What does this mean in terms of the number of test cases to cover the code with respect to its branches?
c. Develop a set of test cases to achieve full path coverage.

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!