Professional Documents
Culture Documents
3 Decision Table
1. Triangle problem
Experiment Content
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. Assume that the upper limit for the size of any side is 10.
Derive test cases for your program based on boundary value analysis, execute the test cases and
discuss the results.
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
Program Code
def triangle():
print('enter value for a: ')
a = int(input())
print('enter value for b: ')
b = int(input())
print('enter value for c: ')
c = int(input())
if((a>10) | (b>10) | (c>10)):
print('out of range')
exit()
if((a<b+c) & (b<a+c) & (c<a+b)):
if((a==b) & (b==c)):
print('Equilateral triangle')
elif ((a!=b) & (a!=c) & (b!=c)):
print('Scalene triangle')
else:
print('Isosceles triangle')
else:
print('Triangle cannot be found')
triangle()
COLLEGE OF MC―--Department of SE--- Experiment Report of Software Quality Assurance and Testing
conditions Rule1 Rule2 Rule3 Rule4 Rule5 Rule6 Rule7 Rule8 Rule9 Rule10
C1: a < b + c T T T F T T T T T T
C2: b < a + c T T T T T T T T T T
C3: c < a + b F T F T T T T T F T
C4: a = b F T F F T F T F F F
C5: a = c F T F F F T T F F F
C6: b = c F T F F F T T F F F
A1: Not a triangle X X
A2: scalene X X X
A3: isosceles X X
A4: equilateral X X
A5: impossible X
Expected
Case ID a b c
Output
DT1 1 2 3 Not a Triangle
DT2 1 1 1 Equilateral
DT3 9 8 5 Scalene
DT4 10 1 0 Out of Range
DT5 2 2 3 Isosceles
DT6 4 5 4 Isosceles
DT7 8 8 8 Equilateral
3 / 17
DT8 7 5 3 Scalene
DT9 1 5 8 Not a Triangle
DT10 5 6 8 Scalene
Rule Counting
c1: a<b+c? T T T F T T T T T T
c2: b<a+c? T T T T T T T T T T
c3: c<a+b? F T F T T T T T F T
c4: a = b? F T F F T F T F F F
c5: a = c? F T F F F T T F F F
c6: b = c? F T F F F T T F F F
Rule count 16 1 1 1 1 1 1 1 8 1
a 1 : N o t a
X X
triangle
a2: Scalene X X X
a3: Isosceles X X
a4: Equilateral X X
a5: Impossible X
Experiment Content
Design, develop, code and run the program in any suitable language to implement the
Next Date
function. Analyze it from the perspective of boundary value testing, derive different
test cases,
execute these test cases and discuss the test results.
NextDate Function(1812≤year≤2012)
NextDate is a function has three variables (month, day, and year), for years from 1812
to 2012.
it return the next date which user input. Month, day and year are all integer, and
satisfy these
conditions below:
1 ≤ month ≤ 12
1 ≤ day≤ 31
1812 ≤ year ≤ 2012Equilateral
Algorithm
STEP 1: Input date in format DD.MM.YYYY
STEP2: if MM is 01, 03, 05,07,08,10 do STEP3 else STEP6
S T E: P i3 f D D < 3 1 t h e n d o S T E P 4 e l s e i f D D =
output(InvalidDate);
STEP4: tomorrowday=DD+1 goto STEP18
STEP5: tomorrowday=1; tomorrowmonth=month + 1 goto STEP18
STEP6: if MM is 04, 06, 09, 11 do STEP7
STEP7: if DD<30 then do STEP4 else if DD=30 do STEP5 else output(InvalidDate);
STEP8: if MM is 12
STEP9: if DD<31 then STEP4 else STEP10
STEP10: tomorrowday=1, tommorowmonth=1, tommorowyear=YYYY+1; goto
STEP18
STEP11: if MM is 2
STEP12: if DD<28 do STEP4 else do STEP13
STEP13: if DD=28 & YYYY is a leap do STEP14 else STEP15
STEP14: tommorowday=29 goto STEP18
STEP15: tommorowday=1, tomorrowmonth=3, goto STEP18;
STEP16: if DD=29 then do STEP15 else STEP17
STEP17: output(“Cannot have feb”, DD); STEP19
STEP18: output(tomorrowday, tomorrowmonth, tomorrowyear);
STEP19: exit
Program Code
PROGRAM CODE:
year = int(input("Input a year: "))
if (year % 400 == 0):
leap_year = True
elif (year % 100 == 0):
leap_year = False
elif (year % 4 == 0):
leap_year = True
else:
leap_year = False
month = int(input("Input a month [1-12]: "))
if month in (1, 3, 5, 7, 8, 10, 12):
month_length = 31
elif month == 2:
if leap_year:
month_length = 29
else:
month_length = 28
else:
month_length = 30
day = int(input("Input a day [1-31]: "))
if day < month_length:
day += 1
else:
day = 1
if month == 12:
month = 1
year += 1
else:
month += 1
print("The next date is [yyyy-mm-dd] %d-%d-%d." % (year, month, day))
CONDITIONS R1 R2 R3
C1: month in M1 T - -
C2: month in M2 - T -
C3: month in M3 - - T
A1: impossible
A2: Next Date
NextDate Decision Table (first half)
M1: 30 days months, M2: 31 days months, M3: Dec, M4: Feb
D1: 1~27, D2: 28, D3: 29, D4: 30, D5: 31
Y1: leap year, Y2: common year
1 2 3 4 5 6 7 8 9 10
c 1 : m o n t hM1 M1 M1 M1 M1 M2 M2 M2 M2 M2
in
c2: day in D1 D2 D3 D4 D5 D1 D2 D3 D4 D5
c3: year in — — — — — — — — — —
a1: X
impossible
a2: X X X X X X X
increment
day
a 3 : r e s e t X X
day
a4: X X
increment
month
a 5 : r e s e t
month
a6:
increment
year
c1: month M3 M3 M3 M3 M3 M4 M4 M4 M4 M4 M4 M4
in
c2: day in D1 D2 D3 D4 D5 D1 D2 D2 D3 D3 D4 D5
c3: year in — — — — — — Y1 Y2 Y1 Y2 — —
a1: X X X
impossibl
e
a2: X X X X X X
increment
day
a3: reset X X X
day
a4: X X
increment
month
a5: reset X
month
a6: X
increment
year
1 1– 3 4 15 2001 4/16/2001
2 4 4 30 2001 5/1/2001
5 10 1 31 2001 2/1/2001
6 11–14 12 15 2001 12/16/2001
7 15 12 31 2001 1/1/2002
8 16 2 15 2001 2/16/2001
9 17 2 28 2004 2/29/2004
10 18 2 28 2001 3/1/2001
Summary
Decision table is based on logical relationships just as the truth table. It is a tool that
helps us look at the “complete” combination of conditions