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

Study the following C++ fuction carefully, float compute_bill(char c, float x, f

ID: 3578267 • Letter: S

Question

Study the following C++ fuction carefully,

float compute_bill(char c, float x, float y){

if ((x>=0.0) && (x<=10.))

                ret = 8.0*x;

                ret = 5.0*x;

if ( c == 'c' )

                ret = ret +y;

else if ( c == 'p')

                ret = ret +0.5*y;

                else if ( c == 'v')

                ret = ret +0.2*y;

else if ( c == 's')

ret = ret +0.1*y;

else {

cout << "Invalid input";

return(-1);

}

return(ret);

}

In order to have branch coverage in white box testing on the function, list the input and the expected outputs of every test case:

Explanation / Answer

Case 1:

Inputs:-

char c='a';

float x=5.5f;

float y=7.5f;

Output :-

Case 2:-

Inputs:-

char c='c';

float x=5.5f;

float y=7.5f;

Output:-

Case 3:-

Inputs :-

char c='p';
float x=5.55f;
float y=7.52f;

Output:-

Case 4:-

Input :-

char c='s';
float x=1.5f;
float y=4.2f;

Outputs:-