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

a. “Testing can only show the presence of errors in a program. It cannot demonst

ID: 3579418 • Letter: A

Question

a. “Testing can only show the presence of errors in a program. It cannot demonstrate that there are no remaining faults”

Based on the statement above, explain why testing can only detect the presence of errors, not their absence.

b. Based on coding, answer the following question:

#include <iostream>
Using Namespace std;
double total,hours;

int main()

{
   cout << "Charges for the first 3 hours = RM2.00" << endl;
   cout << "Additional charges for the next hours = RM1.50"
   << endl; cout << "Maximum charges for any 24 hours = RM20.00"
   << endl; cout << " Please insert your hours = ";
   cin >> hours;

   if ((hours <=3) && (hours > 0))
       cout << " Your total fee is RM2.00" << endl;

   else
       if ((hours>3) && (hours<=15))
   {
  
       total = 2.00+((hours-3)*1.50);
       cout << " Your total fee is RM" << total << endl;

   }
   else
       if (hours>15)

   {
       cout << " Your total fee is RM20.00" << endl;

   }
   else

       cout << " Error! Please insert a valid number of hours" <<

endl;

   system(“PAUSE”); return 0;

   }

i. Draw a Flow Graph for the procedure in coding above

ii. Calculate the cyclomatic complexity of coding procedure

iii. Identify and list down all independent paths based on your answer in (i)

iv. Design a test case to force execution down each independent path. Use a table when designing your test cases

Explanation / Answer

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class GuiAccTest extends Frame implements ActionListener

come msg;
}
public void actionPerformed(ActionEvent ae)
  
}
class BankAccount

public void deposit(int amt)
  
public void withdraw(int amt) throws FundsInsufficientException
  
}
class FundsInsufficientException extends Exception

public String toString()
{
come "Your withdraw quantity ("+withdraw_amount+") is a smaller amount than the balance ("+balance+"). No withdrawal was recorded.";
}
}