18isl67 New ST Manual
18isl67 New ST Manual
REQUIREMENTS:
R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides
of the triangle.
R2. Based on the input should determine if a triangle can be formed or not.
R3. If the requirement R2 is satisfied then the system should determine the type of the
triangle, which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e Two sides are equal)
• Scalene (i.e All the three sides are unequal)
R4. Upper Limit for the size of any side is 10
DESIGN:
ALGORITHM:
Step 1: Input a, b & c i.e three integer values which represent three sides of the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c < (a + b) then do step 3
else
print not a triangle. do step 6.
Step 3: if (a=b) and (b=c) then
Print triangle formed is equilateral. do step 6.
Step 4: if (a ≠ b) and (a ≠ c) and (b ≠ c) then
Print triangle formed is scalene. do step 6.
Step 5: Print triangle formed is Isosceles.
Step 6: stop
DEPARTMENT OF ISE 1
SOFTWARE TESTING LABORATORY
PROGRAM CODE:
#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
if((a > 10) || (b > 10) || (c > 10))
{
printf("Out of range");
exit(0);
}
if((a<b+c)&&(b<a+c)&&(c<a+b))
{
if((a==b)&&(b==c))
{
printf("Equilateral triangle");
}
else if((a!=b)&&(a!=c)&&(b!=c))
{
printf("Scalene triangle");
}
else
printf("Isosceles triangle");
}
else
{
printf(“triangle cannot be formed”);
}
return 0;
}
DEPARTMENT OF ISE 2
SOFTWARE TESTING LABORATORY
TESTING:
0≤a≤10
0≤b≤10
0≤c≤10
From the above equivalence classes we can derive the following test cases using boundary
value analysis approach.
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for the solving triangle problem is designed, developed and programmed.
Also derived the test cases and executed the test cases using boundary value analysis approach and
the results are verified.
DEPARTMENT OF ISE 3
SOFTWARE TESTING LABORATORY
/*Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of boundary value testing, derive
different test cases, execute these test cases and discuss the test results.*/
REQUIREMENTS:
Problem Definition: The Commission Problem includes a salesperson in the former Arizona Territory
sold rifle locks, stocks and barrels made by a gunsmith in Missouri. Cost includes
Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were such that the
most the salesperson could sell in a month was 70 locks, 80 stocks and 90 barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the number of locks,
stocks and barrels sold in the town. At the end of the month, the sales person sent a very short telegram
showing --1 lock sold. The gunsmith then knew the sales for the month were complete and computed
the salesperson’s commission as follows:
On sales up to(and including) $1000= 10%,On the sales up to(and includes) $1800= 15%, On the sales
in excess of $1800= 20%. The commission program produces a monthly sales report that gave the total
number of locks, stocks and barrels sold, the salesperson’s total dollar sales and finally the commission.
DESIGN:
ALGORITHM:
STEP 3: while(locks!=-1) ‘input device uses -1 to indicate end of data goto STEP 12
STEP 8: commission=0.10*1000.0;
commission=commission+0.15 *800.0;
commission = commission + 0.20 * (sales-1800.0)
DEPARTMENT OF ISE 4
SOFTWARE TESTING LABORATORY
PROGRAM CODE:
#include<stdio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70))
{
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80))
{
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90))
{
flag = 1;
}
if (flag == 1)
{
printf("invalid input");
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000)
{
commission = 0.10 * t_sales;
DEPARTMENT OF ISE 5
SOFTWARE TESTING LABORATORY
}
else if (t_sales < 1800)
{
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
else
{
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
printf("The total sales is %d \n The commission is %f",t_sales, commission);
return;
}
TESTING:
‘Boundary value analysis’ testing technique is used to identify errors at boundaries rather than finding
those exist in center of input domain.
Boundary value analysis is a next part of Equivalence partitioning for designing test cases where test
cases are selected at the edges of the equivalence classes.
BVA: Procedure
1. Partition the input domain using unidimensional partitioning. This leads to as many partitions as
there are input variables. Alternately, a single partition of an input domain can be created using
multidimensional partitioning. We will generate several sub-domains in this step.
2. Identify the boundaries for each partition. Boundaries may also be identified using special
relationships amongst the inputs.
3. Select test data such that each boundary value occurs in at least one test input.
4. BVA: Example: Create equivalence classes
The Commission Problem takes locks, stocks and barrels as input and checks it for validity. If it is
valid, it returns the commission as its output. Here we have three inputs for the program, hence n =3.
Since BVA yields (4n +1) test cases according to single fault assumption theory, hence we can say
that the total number of test cases will be (4*3+1)=12+1=13.
DEPARTMENT OF ISE 6
SOFTWARE TESTING LABORATORY
The b o u n d a r y v a l u e test cases can be generated over output by using following constraints:
From the above equivalence classes we can derive the test cases using boundary value analysis
approach.
TC Id Test Case Input Data Expected Output Actual
Statu
Sales (Commission)
Description Locks Stocks Barrels Output s
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for the solving commission problem is designed, developed and
programmed. Also derived the test cases and executed the test cases using boundary value analysis
approach and the results are verified.
DEPARTMENT OF ISE 7
SOFTWARE TESTING LABORATORY
/*Design, develop, code and run the program in any suitable language to implement
the NextDate function. Analyze it from the perspective of boundary value testing,
derive different test cases, execute these test cases and discuss the test results.*/
REQUIREMENTS:
Problem Definition: "Next Date" is a function consisting of three variables like: month, date and
year. It returns the date of next day as output. It reads current date as input date.
C1: 1 ≤ month ≤ 12
C2: 1 ≤ day ≤ 31
C3: 1812 ≤ year ≤ 2012.
If any one condition out of C1, C2 or C3 fails, then this function produces an output "value of month
not in the range 1...12".
Since many combinations of dates can exist, hence we can simply displays one message for this
function: "Invalid Input Date".
A very common and popular problem occurs if the year is a leap year. We have taken into consideration
that there are 31 days in a month. But what happens if a month has 30 days or even 29 or 28 days?
A year is called as a leap year if it is divisible by 4, unless it is a century year. Century years are leap
years only if they are multiples of 400. So, 1992, 1996 and 2000 are leap years while 1900 is not a
leap year.
DESIGN:
ALGORITHM:
DEPARTMENT OF ISE 8
SOFTWARE TESTING LABORATORY
STEP8: if MM is 12
STEP11: if MM is 2
STEP19: exit
PROGRAM CODE:
#include<stdio.h>
int main()
{
int td,tm,ty;
int d,m,y;
printf("enter todays date in the form of MM,DD,YYYY\n");
scanf("%d%d%d",&m,&d,&y);
td=d;
tm=m;
ty=y;
if(m==1||m==3||m==5||m==7||m==8||m==10)
{
if((d<31)&&(d>0))
{
td=d+1;
}
else if(d==31)
{
DEPARTMENT OF ISE 9
SOFTWARE TESTING LABORATORY
td=1;
tm=m+1;
}
else
{
printf("day out of range\n");
}
}
else if(m==4||m==6||m==9||m==11)
{
if(d<30)
{
td=d+1;
}
else
{
td=1;
tm=m+1;
}
}
else if(m==12)
{
if(d<31)
{
td=d+1;
}
else
{
td=1;
tm=1;
ty=y+1;
printf("%d is over\n",y);
}
}
else if(m==2)
{
if(d<28)
{
td=d+1;
}
else
{
if(d==28)
{
DEPARTMENT OF ISE 10
SOFTWARE TESTING LABORATORY
if((y%4)!=0)
{
td=1;
tm=m+1;
}
else
{
td=d+1;
}
}
else
{
if(d==29)
{
td=1;
tm=m+1;
}
else
{
printf("invalid date in feb\n");
}
}
}
}
else
{
printf("month out of range\n");
}
printf("%d\%d\%d",tm,td,ty);
}
TESTING:
‘Boundary value analysis’ testing technique is used to identify errors at boundaries rather than finding
those exist in center of input domain.
Boundary value analysis is a next part of Equivalence partitioning for designing test cases where test
cases are selected at the edges of the equivalence classes.
DEPARTMENT OF ISE 11
SOFTWARE TESTING LABORATORY
The boundary value test cases can be generated by using following constraints
C1: 1 ≤MM ≤ 12
C2: 1 ≤ DD ≤ 31
C3: 1812 ≤ YYYY ≤ 2012.
Here from these constraints we can extract the test cases using the values of MM, DD, and YYYY.
The following equivalence classes can be generated for each variable.
From the above equivalence classes we can derive the test cases using boundary value analysis
approach.
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for the solving NextDate function is designed, developed and programmed. Also
derived the test cases and executed the test cases using boundary value analysis approach and the
results are verified.
DEPARTMENT OF ISE 12
SOFTWARE TESTING LABORATORY
R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides
of the triangle.
R2. Based on the input should determine if a triangle can be formed or not.
R3. If the requirement R2 is satisfied then the system should determine the type of the
triangle, which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e. two sides are equal)
• Scalene (i.e. All the three sides are unequal)
R4. Upper Limit for the size of any side is 10
DESIGN:
DEPARTMENT OF ISE 13
SOFTWARE TESTING LABORATORY
PROGRAM CODE:
#include <stdio.h>
void main()
{
int a,b,c,d1,d2,d3,istry;
printf("enter the three sides of the triangle within the rang\n");
scanf("%d%d%d",&a,&b,&c);
d1=((1<=a)&&(a<=10));
d2=((1<=b)&&(b<=10));
d3=((1<=c)&&(c<=10));
if(!d1)
{
printf("a is out of range\n");
}
if(!d2)
{
printf("b is out of range\n");
}
if(!d3)
{
printf("c is out of range\n");
}
else
{
printf(“Side a is:%d”,a);
printf(“Side b is:%d”,b);
printf(“Side c is:%d”,c);
if(a<(b+c) && b<(a+c) && c<(a+b))
{
istry=1;
if(istry==1)
{
if((a==b)&&(b==c))
{
printf("triangle is equilateral\n");
}
else
{
if((a!=b)&&(a!=c)&&(b!=c))
{
printf("the triangle is scalene\n");
}
else
{
printf("the triangle is isoceles\n");
DEPARTMENT OF ISE 14
SOFTWARE TESTING LABORATORY
}
}
}
else
{
printf("triangle not possible\n");
}
}
}
TESTING:
Equivalence class partitioning technique focus on the Input domain, we can obtain a richer
set of test cases. What are some of the possibilities for the three integers, a, b, and c? They
can all be equal, exactly one pair can be equal.
The maximum limit of each side a, b, and c of the triangle is 10 units according to
requirement R4. So a, b and c lies between
0≤a≤10
0≤b≤10
0≤c≤10
Weak normal a n d s t r o n g n o r m a l equivalence class test cases:
DEPARTMENT OF ISE 15
SOFTWARE TESTING LABORATORY
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for the solving triangle problem is designed, developed and programmed.
Also derived the test cases and executed the test cases using Equivalence Class partitioning
approach and the results are verified.
DEPARTMENT OF ISE 16
SOFTWARE TESTING LABORATORY
/*Design, develop, code and run the program in any suitable language to solve
the commission problem. Analyze it from the perspective of equivalence class
testing, derive different test cases, execute these test cases and discuss the test
results.*/
REQUIREMENTS:
Problem Definition: The Commission Problem includes a salesperson in the former Arizona
Territory sold rifle locks, stocks and barrels made by a gunsmith in Missouri. Cost includes:
Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were such
that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90 barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the number
of locks, stocks and barrels sold in the town. At the end of the month, the sales person sent a very
short telegram showing -1 lock sold.
The gunsmith then knew the sales for the month were complete and computed the
salesperson’s commission as follows: On sales up to (and including) $1000= 10%, On the sales up
to (and includes) $1800= 15% , On the sales in excess of $1800= 20%. The commission program
produces a monthly sales report that gave the total number of locks, stocks and barrels sold, the
salesperson’s total dollar sales and finally the commission.
DESIGN:
PROGRAM CODE:
#include<stdio.h>
int main()
int c1,c2,c3,temp;
lprice=45.0;
sprice=30.0;
bprice=25.0;
tlocks=0;
DEPARTMENT OF ISE 17
SOFTWARE TESTING LABORATORY
tstocks=0;
tbarrels=0;
printf("\nenter the number of locks and to exit the loop enter -1 for locks\n");
scanf("%d",&locks);
while(locks!=-1)
scanf("%d%d",&stocks,&barrels);
c1=(locks<=0||locks>70);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
else
temp=tlocks+locks;
if(temp>70)
printf("new total locks =%d not in the range 1..70 so old ",temp);
else
tlocks=temp;
if(c2)
else
temp=tstocks+stocks;
if(temp>80)
DEPARTMENT OF ISE 18
SOFTWARE TESTING LABORATORY
printf("new total stocks =%d not in the range 1..80 so old ",temp);
else
tstocks=temp;
printf("total stocks=%d\n",tstocks);
if(c3)
else
temp=tbarrels+barrels;
if(temp>90)
printf("new total barrels =%d not in the range 1..90 so old ",temp);
else
tbarrels=temp;
printf("total barrel=%d",tbarrels);
printf("\nenter the number of locks and to exit the loop enter -1 for locks\n");
scanf("%d",&locks);
sales = lprice*tlocks+sprice*tstocks+bprice*tbarrels;
if(sales > 0)
comm=0.10*1000.0;
comm=comm+0.15*800;
DEPARTMENT OF ISE 19
SOFTWARE TESTING LABORATORY
comm=comm+0.20*(sales-1800.0);
comm =0.10*1000;
comm=comm+0.15*(sales-1000);
else
comm=0.10*sales;
else
printf("there is no sales\n");
return 0;
TESTING:
The input domain of the commission problem is naturally partitioned by the limits on locks,
stocks and barrels. These equivalence classes are exactly those that would also be identified
by traditional equivalence class testing.
The first class is the valid input; the other two are invalid. The input domain equivalence classes
lead to very unsatisfactory sets of test cases. Equivalence classes defined on the output range of
the commission function will be an improvement.
DEPARTMENT OF ISE 20
SOFTWARE TESTING LABORATORY
One problem occurs, however. The variables lock are also used as a sentinel to indicate no
more telegrams. When a value of -1 is given for locks, the while loop terminates, and the values
of totallocks, totalstocks and totalbarrels are used to compute sales, and then commission.
Expect for the names of the variables and the interval endpoint values, this is identical to our
first version of the NextDate function. therefore we will have exactly one weak normal
equivalence class test case and again, it is identical to the strong normal equivalence class test
case. Note that the case for locks = -1 just terminates the iteration.
DEPARTMENT OF ISE 21
SOFTWARE TESTING LABORATORY
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for the solving commission problem is designed, developed and
programmed. Also derived the test cases and executed the test cases using Equivalence Class
partitioning approach and the results are verified.
DEPARTMENT OF ISE 22
SOFTWARE TESTING LABORATORY
/*Design, develop, code and run the program in any suitable language to
implement the NextDate function. Analyze it from the perspective of equivalence
class value testing, derive different test cases, execute these test cases and discuss
the test results.*/
REQUIREMENTS:
Problem Definition: "Next Date" is a function consisting of three variables like: month, date
and year. It returns the date of next day as output. It reads current date as input date.
C1: 1 ≤ month ≤ 12
C2: 1 ≤ day ≤ 31
C3: 1812 ≤ year ≤ 2012.
If any one condition out of C1, C2 or C3 fails, then this function produces an output "value of
month not in the range 1...12". Since many combinations of dates can exist, hence we can
simply displays one message for this function: "Invalid Input Date". A very common and
popular problem occurs if the year is a leap year. We have taken into consideration that there
are 31 days in a month. But what happens if a month has 30 days or even 29 or 28 days ?
A year is called as a leap year if it is divisible by 4, unless it is a century year. Century years are
leap years only if they are multiples of 400. So, 1992, 1996 and 2000 are leap years while 1900
is not a leap year.
DESIGN:
PROGRAM CODE:
#include<stdio.h>
int main()
{
int td,tm,ty;
int d,m,y,c1,c2,c3;
printf("enter todays date in the form of MM,DD,YYYY\n");
scanf("%d%d%d",&m,&d,&y);
c1=(1<=d)&&(d<=31);
c2=(1<=m)&&(m<=12);
c3=(1812<=y)&&(y<=2012);
if(!c1)
{
printf("date out of range");
}
else if(!c2)
DEPARTMENT OF ISE 23
SOFTWARE TESTING LABORATORY
{
printf("month out of range");
}
else if(!c3)
{
printf("year out of range");
}
else if(!c1||!c2||!c3)
{
exit(1);
}
else
{
td=d;
tm=m;
ty=y;
if(m==1||m==3||m==5||m==7||m==8||m==10)
{
if(d<31)
{
td=d+1;
}
else
{
td=1;
tm=m+1;
}
}
if(m==4||m==6||m==9||m==11)
{
if(d<30)
{
td=d+1;
}
else
{
if(d==30)
{
td=1;
tm=m+1;
}
else
{
printf(“Invalid input date\n”);
}
}
}
if(m==12)
{
DEPARTMENT OF ISE 24
SOFTWARE TESTING LABORATORY
if(d<31)
{
td=d+1;
}
else
{
td=1;
tm=1;
ty=y+1;
printf("%d is over\n",y);
}
}
if(m==2)
{
if(d<28)
{
td=d+1;
}
else
{
if(d==28)
{
if((y%4)!=0)
{
td=1;
tm=m+1;
}
else
{
td=d+1;
}
}
else
{
if(d==29)
{
td=1;
tm=m+1;
}
else
{
printf("invalid date in feb\n");
}
}
}
}
printf("%d|%d|%d",tm,td,ty);
}
}
DEPARTMENT OF ISE 25
SOFTWARE TESTING LABORATORY
TESTING:
The NextDate function is a function which will take in a date as input and produces as output
the next date in the Georgian calendar. It uses three variables (month, day and year) which
each have valid and invalid intervals.
Since the number of variables is equal to the number of valid classes, only one weak normal
equivalence class test case occurs, which is the same as the strong normal equivalence class
test case.
DEPARTMENT OF ISE 26
SOFTWARE TESTING LABORATORY
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for the NextDate function is designed, developed and programmed. Also
derived the test cases and executed the test cases using Equivalence Class partitioning approach
and the results are verified.
DEPARTMENT OF ISE 27
SOFTWARE TESTING LABORATORY
/*Design and develop a program in a language of your choice to solve the triangle
problem defined as follows: Accept three integers which are supposed to be the
three sides of a triangle and determine if the three values represent an equilateral
triangle, isosceles triangle, scalene triangle, or they do not form a triangle at all.
Derive test cases for your program based on decision-table approach, execute
the test cases and discuss the results.*/
REQUIREMENTS:
R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3
sides of the triangle. Based on the input it should determine if a triangle can be formed or not.
R2. If the requirement R1 is satisfied then the system should determine the type of the triangle,
which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e Two sides are equal)
• Scalene (i.e All the three sides are unequal)
else suitable error message should be displayed. Here we assume that user gives three positive
integer numbers as input.
DESIGN
Form the given requirements we can draw the following conditions: C1: a<b+c?
C2: b<a+c?
C3: c<a+b?
C4: a=b?
C5: a=c?
C6: b=c?
According to the property of the triangle, if any one of the three conditions C1, C2 and C3 are
not satisfied then triangle cannot be constructed. So only when C1, C2 and C3 are true the
triangle can be formed, then depending on conditions C4, C5 and C6 we can decide what
type of triangle will be formed. (i.e requirement R2).
DESIGN:
PROGRAM CODE:
#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
if((a<b+c)&&(b<a+c)&&(c<a+b))
{
DEPARTMENT OF ISE 28
SOFTWARE TESTING LABORATORY
if((a==b)&&(b==c))
{
printf("Equilateral triangle");
}
else if((a!=b)&&(a!=c)&&(b!=c))
{
printf("Scalene triangle");
}
else
printf("Isosceles triangle");
else
{
printf("triangle cannot be formed");
}
return 0;
}
TESTING:
DEPARTMENT OF ISE 29
SOFTWARE TESTING LABORATORY
a2: Scalene X
a3: Isosceles X X X
a4: Equilateral X
a5: Impossible X X X
The “--“ symbol in the table indicates don’t care values. The table shows the six conditions and
5 actions. All the conditions in the decision table are binary; hence, it is called as “Limited Entry
decision table”.
Each column of the decision table represents a test case. That is, The table is read as follows:
Action: Not a Triangle
1. When condition C1 is false we can say that with the given ‘a’ ‘b’ and ‘c’
values, it’s Not a triangle.
2. Similarly condition C2 and C3, if any one of them are false, we can say that with the
given ‘a’ ‘b’ and ‘c’ values it’s Not a triangle.
Action: Impossible
3. When conditions C1, C2, C3 are true and two conditions among C4, C5, C6 is true, there
is no chance of one conditions among C4, C5, C6 failing. So we can neglect these rules.
Example: if condition C4: a=b is true and C5: a=c is true .Then it is impossible, that
condition C6: b=c will fail, so the action is Impossible.
Action: Isosceles
4. When conditions C1, C2, C3 are true and any one condition among C4, C5 and C6 is
true with remaining two conditions false then action is Isosceles triangle.
Example: If condition C4: a=b is true and C5: a=c and C6: b=c are false, it means two
DEPARTMENT OF ISE 30
SOFTWARE TESTING LABORATORY
Using the decision table we obtain 11 functional test cases: 3 impossible cases,
3 ways of failing the triangle property, 1 way to get an equilateral triangle, 1 way to get a
scalene triangle, and 3 ways to get an isosceles triangle.
Deriving test cases using Decision Table Approach:
Test Cases:
TC Test Case Description Expected Output Actual
a b c Status
ID Output
1 Testing for Requirement 1 4 1 2 Not a Triangle
2 Testing for Requirement 1 1 4 2 Not a Triangle
3 Testing for Requirement 1 1 2 4 Not a Triangle
4 Testing for Requirement 2 5 5 5 Equilateral
5 Testing for Requirement 2 2 2 3 Isosceles
6 Testing for Requirement 2 2 3 2 Isosceles
7 Testing for Requirement 2 3 2 2 Isosceles
8 Testing for Requirement 2 3 4 5 Scalene
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for solving the triangle problem is designed, developed and programmed. Also
derived the test cases and executed the test cases using decision table approach and the results are
verified.
DEPARTMENT OF ISE 31
SOFTWARE TESTING LABORATORY
/*Design, develop, code and run the program in any suitable language to solve
the commission problem. Analyze it from the perspective of decision table-based
testing, derive different test cases, execute these test cases and discuss the test
results.*/
REQUIREMENTS:
R1: The system should read the number of Locks, Stocks and Barrels sold in a month.
(i.e 1≤ Locks≤ 70)
(i.e 1Stocks ≤ 80)
(i.e 1 ≤ Barrels ≤ 90).
R2: If R1 is satisfied the system should compute the salesperson’s commission depending on the
total number of Locks, Stocks & Barrels sold else it should display suitable error message.
Following is the percentage of commission for the sales done:
10% on sales up to (and including) $1000
15% on next $800
20% on any sales in excess of $1800
Also the system should compute the total dollar sales. The system should output salespersons
total dollar sales, and his commission.
DESIGN:
Form the given requirements we can draw the following conditions:
C1: 1≤locks≤70? Locks = -1? (occurs if locks = -1 is used to control input iteration).
C2: 1≤stocks≤80?
C3: 1≤barrels≤90?
C4: sales>1800?
DEPARTMENT OF ISE 32
SOFTWARE TESTING LABORATORY
PROGRAM CODE:
#include<stdio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70))
{
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80))
{
flag = 1;
}
printf("Enter the total number of barrels");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90))
{
flag = 1;
}
if (flag == 1)
{
printf("invalid input");
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000)
{
commission = 0.10 * t_sales;
}
else if (t_sales < 1800)
{
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
else
DEPARTMENT OF ISE 33
SOFTWARE TESTING LABORATORY
{
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
printf("The total sales is %d \n The commission is %f",t_sales, commission);
return;
}
}
TESTING:
Technique Used: Decision Table Approach
The decision table is given below
Using the decision table we get 6 functional test cases: 3 cases out of range, 1 case each for
sales greater than $1800, sales greater than $1000, sales less than or equal to $1000.
DEPARTMENT OF ISE 34
SOFTWARE TESTING LABORATORY
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for solving the commission problem is designed, developed and programmed.
Also derived the test cases and executed the test cases using decision table approach and the
results are verified.
DEPARTMENT OF ISE 35
SOFTWARE TESTING LABORATORY
Problem Definition: The Commission Problem includes a salesperson in the former Arizona
Territory sold rifle locks, stocks and barrels made by a gunsmith in Missouri. Cost includes
Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits
were such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90
barrels. After each town visit, the sales person sent a telegram to the Missouri gunsmith
with the number of locks, stocks and barrels sold in the town. At the end of the month, the
salesperson sent a very short telegram showing -1 lock sold. The gunsmith then knew the
sales for the month were complete and computed the salesperson’s commission as follows:
On sales up to(and including) $1000= 10%
On the sales up to(and includes) $1800= 15%
On the sales in excess of $1800= 20%.
The commission program produces a monthly sales report that gave the total number of
locks, stocks and barrels sold, the salesperson’s total dollar sales and finally the commission.
DESIGN :
Price:
Locks-$45
Stocks-$30
Barrels-$25
Range:
1<=locks<=70
1<=Stocks<=80
1<=barrels<=90
Commision:
On sales up to(and including) $1000= 10% commision
On the sales up to(and includes) $1800= 15% commision
On the sales in excess of $1800= 20% commision
DEPARTMENT OF ISE 36
SOFTWARE TESTING LABORATORY
PROGRAM CODE:
24 lsales = lprice*tlocks;
25 ssales=sprice*tstocks;
26 bsales=bprice*tbarrels;
27 sales=lsales+ssales+bsales;
28 printf("\nthe total sales=%f\n",sales);
29 if(sales > 1800.0)
30 {
31 comm=0.10*1000.0;
32 comm=comm+0.15*800;
33 comm=comm+0.20*(sales-1800.0);
}
34 else if(sales > 1000)
35 {
36 comm =0.10*1000;
37 comm=comm+0.15*(sales-1000); }
38 else
39 comm=0.10*sales;
40 printf("the commission is=%f\n",comm);
41 return 0;
42 }
DEPARTMENT OF ISE 37
SOFTWARE TESTING LABORATORY
DEPARTMENT OF ISE 38
SOFTWARE TESTING LABORATORY
DEPARTMENT OF ISE 39
SOFTWARE TESTING LABORATORY
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for solving the commission problem is designed, developed and programmed.
Also derived the test cases and executed the test cases using data flow testing and the results are
verified.
DEPARTMENT OF ISE 40
SOFTWARE TESTING LABORATORY
DESIGN:
We use integer array as a data structure to store ‘n’ number of elements. Iterative
programming technique is used.
ALGORITHM:
Step 1: Input value of ‘n’. Enter ‘n’ integer numbers in array int mid;
Step 2: Initialize low = 0, high = n -1
Step 3: until ( low <= high ) do
mid = (low + high) / 2
if ( a[mid] == key )
then do Step 5
else if ( a[mid] > key ) then do
high = mid - 1
else
low = mid + 1
Step 4: Print unsuccessful search do step 6.
Step 5: Print Successful search. Element found at position mid+1.
Step 6: Stop.
DEPARTMENT OF ISE 41
SOFTWARE TESTING LABORATORY
PROGRAM CODE:
1. #include<stdio.h>
2. int main()
3. {
4. int a[20],n,low,high,mid,key,i,flag=0;
5. printf("Enter the value of n:\n");
scanf("%d",&n);
6. if(n>0)
7. {
8. printf("Enter %d elements in ASCENDING order\n",n);
9. for(i=0;i<n;i++)
10. {
scanf("%d",&a[i]);
11. }
12. printf("Enter the key element to be searched\n");
scanf("%d",&key);
13. low=0;
14. high=n-1;
15. while(low<=high)
16. {
17. mid=(low+high)/2;
18. if(a[mid]==key)
19. {
20. flag=1;
21. break;
22. }
23. else if(a[mid]<key)
24. low=mid+1;
25. else
26. high=mid-1;
27. }
28. if(flag==1)
29. printf("Successful search\n Element found at Location%d\n",mid+1);
30. else
31. printf("Key Element not found\n");
32. }
33. else
34. printf("Wrong input");
35. }
DEPARTMENT OF ISE 42
SOFTWARE TESTING LABORATORY
TESTING:
Technique Used: Basis Path Testing
Basis path testing is a form of Structural testing (White Box testing).
The method devised by McCabe to carry out basis path testing has four steps.
These are:
1. Compute the program graph.
2. Calculate the cyclomatic complexity.
3. Select a basis set of paths.
4. Generate test cases for each of these paths.
Program graph:
DEPARTMENT OF ISE 43
SOFTWARE TESTING LABORATORY
Using the program graph we derive (Decision-to-Decision) DD path graph for binary search program:
DEPARTMENT OF ISE 44
SOFTWARE TESTING LABORATORY
Testing for
2 requirement 2 Path P2
Testing for
3 requirement 2 Path P3
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for solving the binary search problem is designed, developed and programmed. Also
derived the test cases and executed the test cases using basis path testing method and the results are verified.
DEPARTMENT OF ISE 45
SOFTWARE TESTING LABORATORY
DESIGN:
We use integer array as a data structure to store ‘n’ number of elements. Iterative programming
technique is used.
PROGRAM CODE:
1. #include<stdio.h>
2. void quicksort(int [],int,int);
3. int main()
4. {
5. int num[50],i,j,n;
6. printf(“Enter number of elements:”);
7. scanf(“%d”,&n);
8. printf(“\nEnter the elements:”);
9. for(i=0;i<n;i++)
10. scanf(“%d”,&num[i]);
11. quicksort(num,0,n-1);
12. printf(“\nArray after sorting:”);
13. for(i=0;i<n;i++)
14. printf(“%d”,num[i]);
15. printf(“\n”);
16. }
17. void quicksort(int num[],int first,int last)
18. {
19. int i,j,pivot,temp;
20. if(first<last)
21. {
22. pivot=first;
23. i=first;
24. j=last;
25. while(i<j)
26. {
27. while(num[i]<=num[pivot]&&i<last)
28. i++;
29. while(num[j]>num[pivot])
DEPARTMENT OF ISE 46
SOFTWARE TESTING LABORATORY
30. j--;
31. if(i<j)
32. {
33. temp=num[i];
34. num[i]=-num[j];
35. num[j]=temp;
36. }
37. }
38. temp=num[pivot];
39. num[pivot]=num[j];
40. num[j]=temp;
41. quicksort(num,first,j-1);
42. quicksort(num,j+1,last);
43. }
44. }
TESTING:
Technique Used: Basis Path Testing
Basis path testing is a form of Structural testing (White Box testing).
The method devised by McCabe to carry out basis path testing has four steps.
These are:
1. Compute the program graph.
2. Calculate the cyclomatic complexity.
3. Select a basis set of paths.
4. Generate test cases for each of these paths.
Program graph:
DEPARTMENT OF ISE 47
SOFTWARE TESTING LABORATORY
Using the program graph we derive (Decision-to-Decision) DD path graph for binary search program:
DEPARTMENT OF ISE 48
SOFTWARE TESTING LABORATORY
Expected output
Test Case Array Actual
TC ID Value of i Status
Description elements Array output
1 Testing for
path P1
2 Testing for
path P2
3 Testing for
path P3
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for solving the quicksort algorithm is designed, developed and programmed. Also
derived the test cases and executed the test cases using basis path testing method and the results are
verified.
DEPARTMENT OF ISE 49
SOFTWARE TESTING LABORATORY
//Program 12: Absolute letter grading procedure using basis path testing
/*Design, develop, code and run the program in any suitable language to implement an
absolute letter grading procedure, making suitable assumptions. Determine the basis
paths and using them derive different test cases, execute these test cases and discuss the
test results.*/
REQUIREMENTS:
R1: The system should accept marks of 6 subjects, each marks in the range 1 to 100.
i.e., for example, 1<=marks<=100
1<=kannada<=100
1<=maths<=100 etc.
R2: If R1 is satisfied ,comp average of marks scored and percentage of the same and depending on
percentage display the grade.
DESIGN:
We can use the total percentage of marks to grade the student marks.
<35 && 0> of percentage make it as FAIL
avmar<=40 && avmar >35 make it as Grade C
avmar<=50 && avmar>40 make it as Grade C+
avmar<=60 && avmar>50 make it as Grade B
avmar<=70 && avmar>60 make it as Grade B+
avmar<=80 && avmar>70 make it as Grade A
avmar<=100 && avmar>80 make it as Grade A+
PROGRAM CODE
1. #include<stdio.h>
2. main()
3. {
4. float kan,eng,hindi,maths,science, sst,avmar;
5. printf("Letter Grading\n");
6. printf("SSLC Marks Grading\n");
7. printf("Enter the marks for Kannada:");
8. scanf("%f",&kan);
9. printf("enter the marks for English:");
10. scanf("%f",&eng);
11. printf("enter the marks for Hindi:");
12. scanf("%f",&hindi);
13. printf("enter the marks for Maths");
14. scanf("%f",&maths);
15. printf("enter the marks for Science:");
16. scanf("%f",&science);
DEPARTMENT OF ISE 50
SOFTWARE TESTING LABORATORY
TESTING:
PROGRAM GRAPH:
DEPARTMENT OF ISE 51
SOFTWARE TESTING LABORATORY
Using the program graph we derive (Decision-to-Decision) DD path graph for absolute
letter grading procedure:
DEPARTMENT OF ISE 52
SOFTWARE TESTING LABORATORY
Expected Actual
TC ID Test Description Input Status
Outpu Output
1 Testing for path P1 t
2 Testing for path P2
3 Testing for path P3
EXECUTION:
Execute the program against the designed test cases and complete the table.
RESULT:
Thus, the program for implementing absolute letter grading procedure is designed, developed
and programmed. Also derived the test cases and executed the test cases using basis path
testing method and the results are verified.
DEPARTMENT OF ISE 53