You are on page 1of 4

Software Testing Assignment 2

Q1. A program takes an angle as input within the range [0,360] and determines in which
quadrant the angle lies. Design test cases using equivalence class partitioning method on the
input and the output domain.
Q2. A university is admitting students in a professional course subject to the following
conditions:
(a) Marks in Java >= 70
(b) Marks in C++ >= 60
(c) Marks in Data Structures >= 60
(d) Total in all three subjects >= 220 OR Total in Java and C++ >=150
If the aggregate marks of an eligible candidate is more than 240, he will be eligible for a
scholarship course, otherwise he will be eligible for normal course. The program reads the
marks in the three subjects and generates the following outputs:
(i) Not Eligible
(ii) Eligible for scholarship course
(iii) Eligible for Normal course
Design test cases for this program using decision table testing.
Q3. Consider a three-input program to handle personal loans of a customer. Its input is a triple
of positive integers (principal, rate, term).
1000 <= principal <= 40000; 1 <= rate <= 18; 1 <= term <= 6
The program should calculate the interest for the whole term of the loan and the total amount
of the personal loan. The output is:
Interest = principal * (rate/100) * term
Total_amount = principal + interest
Generate boundary value and robust test cases.
Q4. Consider the program given below.
/*Program to calculate total telephone bill amount to be paid by an customer*/
#include<stdio.h>
#include<conio.h>
1. void main()
2. {
3. int custnum, numcalls, valid=0;
4. float netamount;
5. clrscr();
6. printf(“Enter customer number and number of calls:”);
7. scanf(“%d %d”,&custnum,&numcalls);
8. if( custnum>10 && custnum<20000) {
9. valid=1;
10. if (numcalls<0){
11. valid=-1;
12. }
13. }
14. if (valid==1){
15. if (numcalls<76){
16. netamount = 500;
17. }
18. else if (numcalls>75 && numcalls<201){
19. netamount = 500 + 0.80*(numcalls-75);
20. }
21. else if (numcalls>200 && numcalls<501){
22. netamount = 500 + 1.00*( numcalls-200);
23. }
24. else{
25. netamount = 500 + 1.20*(numcalls-500);
26. }
27. printf(“\nCustomer number: %d\t Total Charges:%.3f”,custnum,netamount);
28. }
29. else if (valid=0) {
30. printf(“Invalid customer number”);
31. }
32. else{
33. printf(“Invalid number of calls”);
34. }
35. getch();
36. }

(a) Find all du-paths and identify those du-paths that are definition clear. Also find all du-
paths, all-uses and all-definitions and generate test cases for these paths.
(b) Consider all variables and generate possible program slices. Design at least one test
case for every slice
Q5. Consider the program for determination of division of a student. Consider all variables and
generate possible program slices. Design at least one test case from every slice. (code already
given)
Q6. Consider a program for classification of a triangle. Its input is a triple of positive integers
(a,b,c) and the input parameters are greater than zero and less than or equal to 100. The triangle
is classified according to the following rules: (code already given)
Right angled Triangle: c2 = a2 + b2 or a2 = b2 + c2 or b2 = c2 + a2
Obtuse angled Triangle: c2 > a2 + b2 or a2 > b2 + c2 or b2 > c2 + a2
Acute angled Triangle: c2 < a2 + b2 or a2 < b2 + c2 or b2 < c2 + a2
The program output may have one of the following:
[Acute angled triangle, Obtuse angled triangle, Right angled triangle, Invalid Triangle]

(a) Design equivalence class test cases for input and output domain.
(b) Design test cases using decision table testing technique.
(c) Draw the flow graph. Calculate cyclomatic complexity and identify basis paths set.

Q7. The BSE Electrical company charges its domestic consumers using the following slab:
Consumption Units Electricity charges
0-150 2.00 per unit
151-300 Rs 200 + Rs. 3.00 per unit in excess of 150 units
301-400 Rs 300 + Rs. 3.90 per unit in excess of 300 units
>400 Rs 350 + Rs. 4.40 per unit in excess of 400 units

Identify the equivalence class test cases for output and input domain.

Q8. Consider a program to arrange numbers in ascending order from a given list of N numbers.
main()
{
int num,small;
int i,j,sizelist,list[10],pos,temp;
clrscr();
cout<<"Enter size of list/n";
cin>>sizelist;
for(i=o;i<sizelist;i++)
{
cout<<"Enter the number";
cin>>list[i];
}
for(i=0;i<Sizelist;i++)
{
small=list[i];
pos=i;
for(j=i+1;j<sizelist;j++)
{
if(small>list[j])
{
small=list[j];
pos=j;
}
}
temp=list[i];
list[i]=list[pos];
list[pos]=temp;
}
cout<<"list of the numbers in ascending order :";
for(i=0;i<sizelist;i++)
cout<<list[i];
getch();
}
(a) Draw the program flow graph and DD graph for the program.
(b) Calculate the cyclomatic complexity of the program.
(c) List all independent paths.
(d) Design test cases for independent paths.

You might also like