Starting from:
$30

$24

Lab0502 Solution







UML Diagram













employee




age : integer



id : integer



salary : float



setAge(int input) : void



setID(int input) : void



setSalary(float input) : void



getAge() : integer



getID() : integer



getSalary() : float









Class Test Plan Version







Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
Default Constructor
Default
Age = 0
Age = 0
Pass








ID=0
ID=0










Salary = 0.0
Salary = 0.0
















Valid Data
2
Set/Get Age
47
Age = 47
Age = 47
Pass














Valid Data
3
Set/Get ID
777
ID = 777
ID = 777
Pass














Valid Data
4
Set/Get Salary
80,880
Salary = 80880
Salary = 80880
Pass














Invalid Data
1
Set Age
-1
Invalid Age
Invalid Age
Pass














Invalid Data
2
Set ID
-777
Invalid ID
Invalid ID
Pass














Invalid Data
3
Set Salary
-100000
Invalid Salary
Invalid Salary
Pass

















Class Algorithm




Create Class Employee



Create Function



Name: setAge



Parameters: integer input



Return: void



Create Function



Name: setID



Parameters: integer input



Return: void



Create Function



Name: setSalary



Parameters: float input



Return: void



Create Function



Name: getAge



Parameters: n/a



Return: integer



Create Function



Name: getID



Parameters: n/a



Return: integer



Create Function



Name: getSalary



Parameters: n/a



Return: float
Create Main



Test Default Constructor



Test Valid Employee Data



Test Invalid Employee Data






Main Test Plan (Provided Data)







Test
#
Description
Input
Expected Output




Actual Output




Pass
Strategy






















/Fail


























Valid Data
1
Data
Table
Employee
Age
ID
Salary
Employee
Age
ID
Salary
Pass




Provided
1*
1
30
111
30000
-----------------------------------------














2
31
112
31000
1
30
111
30000










3
32
113
32000
2
31
112
31000










4
33
114
33000
3
32
113
32000










5
34
115
34000
4
33
114
33000










6
35
116
35000
5
34
115
34000










Averages
32.5


32500
6
35
116
35000


















-----------------------------------------


















Averages
32.5


32500





































Table 1






Age
ID
Salary








x[0][0]
30
111
30000








x[0][1]
31
112
31000








x[0][2]
32
113
32000








x[1][0]
33
114
33000








x[1][1]
34
115
34000








x[1][2]
35
116
35000














New Main Algorithm




Create Function



Name: printEmployees



Parameters: Array of employee, rows, columns



Return: void



Declare holder and counter variables



Print out heading to table



In nested FOR loop



Print Data for the respective employee in order



Iterate counter



Compound Age



Compound Salary



Calculate Averages



Print Averages



Create Main



Declare 2 Dimensional Employee Array



Set all Ages



Set all IDs



Set all Salaries



printEmployees

More products