Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

l Give an example for each level of training evaluation.

Answered: 1 week ago