Académique Documents
Professionnel Documents
Culture Documents
Condition Stub
Decision Table
Condition Entry(Rules)
T
F
T
F
T
F
T
T
F
Action Stub
T
F
X
X
X
Action entry
X
X
Input
Actual Output
m2
m3
(Phys (Chemi
ics)
stry)
Expected output
Result
m1
(Mathe
matics
40
58
85
60
75
75
70
75
85
80
35
88
60
75
70
70
75
85
Not Eligible
Not Eligible
Not Eligible
Not Eligible
Impossible, I1
Eligible for Pass Course
Impossible, I2
Eligible for Pass Course
Eligible for Honors Course
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
85
78
33
60
50
80
100
75
80
Not Eligible
Not Eligible
Not Eligible
Not Eligible
Impossible, I1
Eligible for Pass Course
Impossible, I2
Eligible for Pass Course
Eligible for Honors Course
I1: If C3 (Marks in Chemistry >=50) and C5 (Total in Mathematics and Physics >=150) are true,
then C4 (Total in all 3 Subjects >=200) has to be true, cant be false. Hence impossible
I2: If C5 (Total in Mathematics and Physics >=150) is false, then even 100 marks in chemistry
cant make the C6 (Total in all 3 Subjects >=250) true. Hence impossible
Question 8: Consider a program below for the selection of the largest of numbers.
import java.util.Scanner;
public class greater
{public static void main(String args[])
{Scanner object = new Scanner(System.in);
int a,b,c;
System.out.print("\nEnter First Number,a: ");
a = object.nextInt();
System.out.print("\nEnter Second Number,b: ");
b = object.nextInt();
System.out.print("\nEnter Third Number,c: ");
c = object.nextInt();
if(a<10 || a>250 || b<10 || b>250 || c<10 || c>250)
System.out.print("\nInvalid Input");
else
{System.out.print("\nLargest Value is: ");
if(a>b)
{if (a>c)
System.out.print(a);
else
System.out.print(c);
}
else
{if (c>b)
System.out.print(c);
else
System.out.print(b);
}
}
}// end of main function
}// end of class greater
i)
ii)
iii)
Design set of test cases using boundary value analysis technique and equivalence
class testing technique. The input may be any valid integer in the range [10-250].
Select a set of test cases that provide 100% statement coverage.
Develop a decision table for this program.
(i)
Test Case Id
1
2
3
4
5
6
7
8
9
10
11
12
13
Input
A
130
130
130
130
130
130
130
130
130
10
11
249
250
B
130
130
130
130
130
10
11
249
250
130
130
130
130
C
10
11
130
249
250
130
130
130
130
130
130
130
130
Expected Output
Actual Output
Result
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
a
0
200
500
225
225
225
225
225
225
Input
b
225
225
225
0
200
500
225
225
225
c
225
225
225
225
225
225
0
200
500
Expected Output
Actual Output
Result
Invalid Input
Largest Value is: 225
Invalid Input
Invalid Input
Largest Value is: 225
Invalid Input
Invalid Input
Largest Value is: 225
Invalid Input
Invalid Input
Largest Value is: 225
Invalid Input
Invalid Input
Largest Value is: 225
Invalid Input
Invalid Input
Largest Value is: 225
Invalid Input
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
ii)
Test Case Id
1
2
3
4
Input
A
0
249
130
130
B
130
130
250
130
C
130
130
130
249
Expected Output
Actual Output
Result
Invalid Input
Largest Value is: 249
Largest Value is: 250
Largest Value is: 249
Invalid Input
Largest Value is: 249
Largest Value is: 250
Largest Value is: 249
Nil
Nil
Nil
Condition
Stub
(iii)
C1: a>b
C2: a>c
F
C3: c>b
T
T
F
T
T
T
Action
Stub
Largest value is a
Largest value is b
Largest value is c
X
X
X
X
Impossible
Action Entry
Test Cases for the decision table
Number of test cases: 8
Input Domains: a: - [10-250]
b: - [10-250]
c: - [10-250]
Number of Values in Output Domain: 4
Output Domains: O1: {<a,b,c>: Invalid Input}
O2: {<a,b,c> : Largest Value is: a}
O3: {<a,b,c> : Largest Value is: b}
O4: {<a,b,c> : Largest Value is: c}
O4: {<a,b,c> : Impossible}
Test Cases
Test
Input
Actual Output
Case a
b
c
id
1
65 75
70
Largest Value is: 75
2
50 80
100 Largest Value is:100
3
150 220 120 Largest Value is:220
4
100 225 75
Impossible, I1
5
240 200 250 Impossible, I2
6
225 200 250 Largest Value is:250
7
175 150 75
Largest Value is:175
8
229 148 159 Largest Value is:229
Expected output
Result
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
I1: If C2 (a>c) and C3 (c>b) are true, then C1 (a>b) is true, cant be false. Hence Impossible
I2: If C2 (a>c) and C3 (c>b) are false, then C1 (a>b) is false too, cant be true. Hence Impossible
Question 9: Write a program for determining the previous date. The input is a triple of day,
month and year with values in the range:
1 <= day <= 31
1<= month <=12
1900 <= year <= 2020
The possible output would be previous date or invalid input date. Design the Boundary value,
Robust and Worst cases for this program.
Code
import java.util.Scanner;
class previousdate
{public static void main(String args[])
{ Scanner object = new Scanner(System.in);
System.out.print("\nEnter the day:");
int day = object.nextInt();
System.out.print("\nEnter the month:");
int month = object.nextInt();
System.out.print("\nEnter the year:");
int year = object.nextInt();
if( (year>2020) || (year<1900) || (month<1) || (month>12) || (day<1) || (day>31) )
{System.out.println("\n\nInvalid Input");
return;
}
int daysallowed;
if( month==1 || month==3 || month==5 || month== 7 || month==8 || month==10 || month==12)
daysallowed = 31;
else if( month==4 || month==6 || month==9 || month== 11)
daysallowed = 30;
else
{ boolean isLeapYear = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));
if(isLeapYear == true)
daysallowed = 29;
else
daysallowed = 28;
}
Test
Case
Id
1
2
3
4
5
6
7
8
9
10
11
12
13
Input
day month year
16
16
16
16
16
16
16
16
16
1
2
30
31
6
6
6
6
6
1
2
11
12
6
6
6
6
1900
1901
1960
2019
2020
1960
1960
1960
1960
1960
1960
1960
1960
Expected Output
15/6/1900
15/6/1901
15/6/1960
15/6/2019
15/6/2020
15/6/1960
15/6/1960
15/11/1960
15/12/1960
31/5/1960
1/6/1960
29/6/1960
30/6/1960
Actual Output
16/6/1900
15/6/1901
15/6/1960
15/6/2019
15/6/2020
15/6/1960
15/6/1960
15/6/1960
15/12/1960
31/5/1960
1/6/1960
29/6/1960
30/6/1960
Result
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Robustness
Number of Inputs, n: 3 (day, month, year)
Input Domains: day: - [1-31]
month: - [1-12]
year: - [1900-2020]
Number of Test Cases: 6(n) + 1
= 6(3) + 1
= 19
Output Domain: O1: {<day,month,year> : previous date}
O2: {<day,month,year> : Invalid Input}
Input
day
0
1
2
16
30
31
32
16
16
16
16
16
16
16
16
16
16
16
16
month
6
6
6
6
6
6
6
0
1
2
11
12
13
6
6
6
6
6
6
year
1960
1960
1960
1960
1960
1960
1960
1960
1960
1960
1960
1960
1960
1899
1900
1901
2019
2020
2021
Expected Output
Actual Output
Result
Invalid Input
31/5/1960
1/6/1960
15/6/1960
29/6/1960
30/6/1960
Invalid Input
Invalid Input
15/1/1960
15/2/1960
15/11/1960
15/12/1960
Invalid Input
Invalid Input
15/5/1900
15/5/1901
15/5/2019
15/5/2020
Invalid Input
Invalid Input
31/5/1960
1/6/1960
15/6/1960
29/6/1960
30/6/1960
Invalid Input
Invalid Input
15/1/1960
15/2/1960
15/11/1960
15/12/1960
Invalid Input
Invalid Input
15/5/1900
15/5/1901
15/5/2019
15/5/2020
Invalid Input
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Input
day
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
year
1900
1901
1960
2019
2020
1900
1901
1960
2019
2020
1900
1901
1960
2019
2020
1900
1901
1960
2019
2020
1900
1901
31/12/1899
31/12/1900
31/12/1959
31/12/2018
31/12/2019
31/1/1900
31/1/1901
31/1/1960
31/1/2019
31/1/2020
31/5/1900
31/5/1901
31/5/1960
31/5/2019
31/5/2020
31/10/1900
31/10/1901
31/10/1960
31/10/2019
31/10/2020
30/11/1900
30/11/1901
31/12/1899
31/12/1900
31/12/1959
31/12/2018
31/12/2019
31/1/1900
31/1/1901
31/1/1960
31/1/2019
31/1/2020
31/5/1900
31/5/1901
31/5/1960
31/5/2019
31/5/2020
31/10/1900
31/10/1901
31/10/1960
31/10/2019
31/10/2020
30/11/1900
30/11/1901
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Test
Case Id
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Input
day month
1
12
1
12
1
12
2
1
2
1
2
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
6
2
6
2
6
2
6
2
6
2
11
2
11
2
11
2
11
2
11
2
12
2
12
2
12
2
12
2
12
6
1
6
1
6
1
6
1
6
1
6
2
6
2
6
2
6
2
30/11/1960
30/11/2019
30/11/2020
1/1/1900
1/1/1901
1/1/1960
1/1/2019
1/1/2020
1/2/1900
1/2/1901
1/2/1960
1/2/2019
1/2/2020
1/6/1900
1/6/1901
1/6/1960
1/6/2019
1/6/2020
1/11/1900
1/11/1901
1/11/1960
1/11/2019
1/11/2020
1/12/1900
1/12/1901
1/12/1960
1/12/2019
1/12/2020
5/1/1900
5/1/1901
5/1/1960
5/1/2019
5/1/2020
5/2/1900
5/2/1901
5/2/1960
5/2/2019
30/11/1960
30/11/2019
30/11/2020
1/1/1900
1/1/1901
1/1/1960
1/1/2019
1/1/2020
1/2/1900
1/2/1901
1/2/1960
1/2/2019
1/2/2020
1/6/1900
1/6/1901
1/6/1960
1/6/2019
1/6/2020
1/11/1900
1/11/1901
1/11/1960
1/11/2019
1/11/2020
1/12/1900
1/12/1901
1/12/1960
1/12/2019
1/12/2020
5/1/1900
5/1/1901
5/1/1960
5/1/2019
5/1/2020
5/2/1900
5/2/1901
5/2/1960
5/2/2019
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Test
Case Id
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Input
day month
6
2
6
6
6
6
6
6
6
6
6
6
6
11
6
11
6
11
6
11
6
11
6
12
6
12
6
12
6
12
6
12
30
1
30
1
30
1
30
1
30
1
30
2
30
2
30
2
30
2
30
2
30
6
30
6
30
6
30
6
30
6
30
11
30
11
30
11
30
11
30
11
30
12
5/2/2020
5/6/1900
5/6/1901
5/6/1960
5/6/2019
5/6/2020
5/11/1900
5/11/1901
5/11/1960
5/11/2019
5/11/2020
5/12/1900
5/12/1901
5/12/1960
5/12/2019
5/12/2020
29/1/1900
29/1/1901
29/1/1960
29/1/2019
29/1/2020
29/2/1900
29/2/1901
29/2/1960
29/2/2019
29/2/2020
29/6/1900
29/6/1901
29/6/1960
29/6/2019
29/6/2020
29/11/1900
29/11/1901
29/11/1960
29/11/2019
29/11/2020
29/12/1900
5/2/2020
5/6/1900
5/6/1901
5/6/1960
5/6/2019
5/6/2020
5/11/1900
5/11/1901
5/11/1960
5/11/2019
5/11/2020
5/12/1900
5/12/1901
5/12/1960
5/12/2019
5/12/2020
29/1/1900
29/1/1901
29/1/1960
29/1/2019
29/1/2020
29/2/1900
29/2/1901
29/2/1960
29/2/2019
29/2/2020
29/6/1900
29/6/1901
29/6/1960
29/6/2019
29/6/2020
29/11/1900
29/11/1901
29/11/1960
29/11/2019
29/11/2020
29/12/1900
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Test
Case Id
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Input
day month
30
12
30
12
30
12
30
12
31
1
31
1
31
1
31
1
31
1
31
2
31
2
31
2
31
2
31
2
31
6
31
6
31
6
31
6
31
6
31
11
31
11
31
11
31
11
31
11
31
12
31
12
31
12
31
12
31
12
29/12/1901
29/12/1960
29/12/2019
29/12/2020
30/1/1900
30/1/1901
30/1/1960
30/1/2019
30/1/2020
30/2/1900
30/2/1901
30/2/1960
30/2/2019
30/2/2020
30/6/1900
30/6/1901
30/6/1960
30/6/2019
30/6/2020
30/11/1900
30/11/1901
30/11/1960
30/11/2019
30/11/2020
30/12/1900
30/12/1901
30/12/1960
30/12/2019
30/12/2020
29/12/1901
29/12/1960
29/12/2019
29/12/2020
30/1/1900
30/1/1901
30/1/1960
30/1/2019
30/1/2020
30/2/1900
30/2/1901
30/2/1960
30/2/2019
30/2/2020
30/6/1900
30/6/1901
30/6/1960
30/6/2019
30/6/2020
30/11/1900
30/11/1901
30/11/1960
30/11/2019
30/11/2020
30/12/1900
30/12/1901
30/12/1960
30/12/2019
30/12/2020
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Question 10: Write a program for grading the students in an academic institution. The grading is
done according to the following rules:
Marks Obtained
80-100
60-79
50-59
40-49
0-39
Grade
Distinction
First Division
Second Division
Third Division
Fail
Input
Expected
marks[0] marks[1] marks[2] marks[3] marks[4] Output
Actual Output
Result
-1
50
101
50
90
50
50
40
50
50
65
50
50
25
50
Invalid Input
Second Division
Invalid Input
Invalid Input
Distinction
Invalid Input
Invalid Input
Third Division
Invalid Input
Invalid Input
First Division
Invalid Input
Invalid Input
Fail
Invalid Input
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
Nil
50
50
50
-1
90
101
50
40
50
50
65
50
50
25
50
50
50
50
50
90
50
-1
40
101
50
65
50
50
25
50
50
50
50
50
90
50
50
40
50
-1
65
101
50
25
50
50
50
50
50
90
50
50
40
50
50
65
50
-1
25
101
Invalid Input
Second Division
Invalid Input
Invalid Input
Distinction
Invalid Input
Invalid Input
Third Division
Invalid Input
Invalid Input
First Division
Invalid Input
Invalid Input
Fail
Invalid Input