1. PROBLEM OVERVIEW.
Summary of a problem:
ICT company has for Departments which are FINANCE , TECHNICAL
OPERATION , HUMAN RESOURCE AND MARKETING and It has total of 500
employees.
It has two type of employees who are TEMPORARY and PERMANENT , it take at
most 100 temporary employee and at most 400 permanent employee.
For TEMPORARY STAFF each department is paid an hourly rate salary of $5 for
working 8 hours/day, 24 days in a month. Annual increment of $0.5/hour is offered to
each temporary staff.
$ 5 per hour for 8 hours/day in 24 days of a month.
Monthly income without annual increment is given as:
$ 5 * 8 hours * 24 days = $ 960.
Monthly income with annual increment is given as:
($ 5 * 8 hours * $ 0.5 * 24 days )+ $ 960 = $ 1440.
Annual income with annual increment is given as:
$ 1440 * 12 months = $4 17,280.
Therefore:
Total monthly income of the Temporary Staff is $ 1440.
Total Annual Income of a Temporary staff is : $ 17,280.
For PERMANENT STAFF each department is paid a monthly initial salary of $1500
with a 5% annual increment of the basic initial salary. The company has a policy of
awarding each permanent staff a yearly bonus of 10% of the annual salary.
Initial salary : $ 1500
5% annual increment (each month of all 12 month in a
year) =( 5/100) * $ 1500 = $ 75
So monthly income with annual increment is given as:
$ 1500 + $ 75
$ 1575.
There fore monthly income with annual increment is
$1575.
1
2. Annual salary income of monthly income without annual
increment is given as:
$ 1500 * 12 months = $ 18,000
Annual salary income of monthly income with annual increment is
given as:
$ 1575 * 12 months = $ 18,900.
Bonus (10% of annual salary)= (10/100) * $ 18,000.
=$ 1,800.
Annual income with all increment and bonus is given as:
TOTAL INCOME = $ 18,900 + $ 1,800.
=$ 20,700.
Therefore:
Total monthly income of a Permanent Staff is $ 1575.
Total Annual income of the Permanent Staff is $ 20,700.
REQUIREMENT IDENTIFICATION:
System to keep Employee’s data including ID number, department name and number
of years a staff has served the company to date (years of service).
Also be able to display ID number, department name, years of service, the current
monthly salary and the annual income of the current year (including bonuses) for each
staff.
Summary structure of ICT Company.
KEY:
2
3. HR = HUMAN RESOURCE.
TECHN.OP = TECHNICAL OPERATION.
DESIGNING.
In the Designing , we will consider three Classes which will be DEPARTMENT ,
TEMPORARY STAFF AND PERMANENT STAFF. This because in each
department name we will find temporary and permanent employees.
Since within Department we will find both temporary and permanent staff then
DEPARTMENT class will be Super Class and TEMPORARY STAFF,PERMANENT
STAFF will be Sub classes that will inherit from DEPARTMENT class.
Logical Design of Classes.
IDENTIFYING OBJECTS , ATTRIBUTES AND METHODS USED IN CLASS
DECLARATION.
Object name: Department
Atributes:
string department_name;
string employ_type;
string employ_id;
int year;
Method:
void set_data (string e_type,string e_id,string dname,int yr){
department_name=dname;
employ_id=e_id;
3
5. Methods:
float get_monthly (){
return (1575);
}
float get_annual (){
return (20700);
}
Algorithm used to design a system.
1.Option:1- to Add new employee, 2- to view saved employee, 0-To exit.
2.receive option, if option is 1 go step 3,Else if 2 go step 23,else if 0 go step 27,else
display Error!enter correct choice; go step 1
3.Please enter current year:
4.receive and save current year.
5.please provide number of employee to be added:
6.receive number_to_add,
7.if number > 500 go next else go step 9 ;
8.number=0; display error! Employee must be less than 501;go step 5
9.Display Menu for further option :
: T- for Temporary employee type, P-for permanent employee.
:1-for Finance department, 2- for Marketing department
:3-for Human resource, 4- for technical operation
10.open loop for i<=number_to_add ; i++ {
11.Enter employee type:
12.receive type
13.Enter employee id
5
6. 14.receive employee id
15.Enter year employee admitted/employed to a company;
16.receive year , if year<=current year go step 18 else go next
17.year=0,display Error!it is out of current year ; go step 15
18.Enter Department number as menu above shown;
19.receive department number, if department number is not equivalent to 1 to 4 go
next, else go step 21
20.display Error!No that department in ICT; go step 18
21.Saving data supplied
22.end loop
23.for(j=0; j<=number;j++){
24.receiving saved data
25.displaying saved data
26.}end loop
27.exit
Codes used to desing phase that interact with the user as Algorithm stated
int main (){ //instace declaration of declared classes;
Temporary_staff temp[100];
Permanent_staff perm[400];
string e_type ,e_id , dname,type,table_title[5];
int yr,choice,number=0,new_number=0,i,v,b,named,current_year=2011; //i,v,b
used by for //loops and choice used by while and other as a variable
choice=1; //variable new_number temporary store
history of added staff number
while(choice!=0){ //when user chose to add again new staff,it
used to display //all histry from the loop
6
7. cout<<"1- TO ADD NEW EMPLOYEE(S):"<<endl; //creating menu for
user interaction;
cout<<"2- TO VIEW AVAILABLE EMPLOYEE(S):"<<endl;
cout<<"0- TO EXIT:"<<endl;
cin>>choice;
if (choice==1){
cout<<"PLEASE ENTER CURRENT YEAR:";
cin>>current_year;cout<<endl;
cout<<"PLEASE PROVIDE NUMBER OF EMPLOYEE YOU WANT TO ADD:";
cin>>number;
if (number>500 || number ==0){ //CHECK USER INPUTS IF WANT TO ADD
1<=STAFF<=500;
cout<<"ERROR! MAXIMUM 500 STAFFS OR MINIMUM 1
STAFF:"<<"REPEATE AGAIN:";
cin>>choice;cout<<endl;}
cout<<"--------------------------HEAD-----------------------------.n";
cout<<"P- FOR PERMANENT STAFF , T- FOR TEMPORARY STAFF:"<<endl;
cout<<"1- FOR FINANCE DEPARTMENT: , 2- FOR MARKETING
DEPARTMENT:"<<endl;
cout<<"3- FOR TECHNICAL OPERATION DEPARTMENT , 4- FOR HR
DEPARTMENT:"<<endl;
cout<<"n";
new_number=new_number+number;
for (i=1;i<=number;i++){
cout<<"*********************"<<endl;
cout<<" EMPLOYEE:"<<" "<<i<<endl;
cout<<"*********************"<<endl;
7
8. cout<<"ENTER EMPLOYEE TYPE (eg:T for temporary):"<<" ";
cin>>type;cout<<endl;
cout<<"EMPLOYEE ID (eg:bcs/10/51752):"<<" ";
cin>>e_id;cout<<endl;
cout<<"YEAR EMPLOYED:"<<" ";
cin>>yr;cout<<endl;
cout<<"DEPARTMENT NUMBER:"<<" ";
cin>>named;cout<<endl;
switch (named){
case 1:
dname="FINANCE.";
if (type=="T" || type=="t"){ //asigning Department names according
e_type="TEMPORARY:"; //to their number inputed by user with type of
temp[i].set_data(e_type,e_id,dname,yr); //inputed employee
}
if (type=="P" || type=="p"){
e_type="PERMANENT:";
perm[i].set_data (e_type,e_id,dname,yr);
break;
}
case 2:
dname="MARKETING.";
if (type=="T" || type=="t"){
e_type="TEMPORARY:";
temp[i].set_data(e_type,e_id,dname,yr);
}
8
9. if (type=="P" || type=="p"){
e_type="PERMANENT:";
perm[i].set_data (e_type,e_id,dname,yr);
break;
}
case 3:
dname="TECHNICAL OPERATION.";
if (type=="T" || type=="t"){
e_type="TEMPORARY:";
temp[i].set_data(e_type,e_id,dname,yr);
}
if (type=="P" || type=="p"){
e_type="PERMANENT:";
perm[i].set_data (e_type,e_id,dname,yr);
break;
}
case 4:
dname="HUMAN RESOURCE.";
if (type=="T" || type=="t"){
e_type="TEMPORARY:";
temp[i].set_data(e_type,e_id,dname,yr);
}
if (type=="P" || type=="p"){
e_type="PERMANENT:";
perm[i].set_data (e_type,e_id,dname,yr);
break;
9
10. }}}}
//TO DISPLAY SAVED RECORDS OF BOTH PERMANENT AND TEMPORARY
STAFF;
if (choice==2){
cout<<"______________________________________________________________
n";
cout<<"TEMPORARY STAFF RECORDS:n";
cout<<"______________________________________________________________
n";
for(v=1;v<=new_number;v++){
cout<<" "<<"RECORD NUMBER:"<<v<<endl<<endl;
cout<<":EMPLOYEE ID:"<<temp[v].get_employ_id()<<endl;
cout<<":DEPARTMENT NAME:"<<temp[v].get_department_name()<<endl;
cout<<":MONTHLY SALARY($):"<<temp[v].get_monthly()<<endl;
cout<<":ANUAL SALARY($):"<<temp[v].get_annual()<<endl;
cout<<":YEARS OF SERVICE:"<<current_year-temp[v].get_year()<<endl;
cout<<":EMPLOYEE TYPE:"<<temp[v].get_employ_type()<<endl;
cout<<"--------------------------------------------------------------n";
}cout<<endl;
cout<<"______________________________________________________________
n";
cout<<"PERMANENT STAFF RECORDS:n";
cout<<"______________________________________________________________
n";
for (b=1;b<=new_number;b++){
cout<<" "<<"RECORD NUMBER:"<<v<<endl<<endl;
10
11. cout<<":EMPLOYEE ID:"<<perm[b].get_employ_id()<<endl;
cout<<":DEPARTMENT NAME:"<<perm[b].get_department_name()<<endl;
cout<<":MONTHLY SALARY($):"<<perm[b].get_monthly()<<endl;
cout<<":ANUAL SALARY($):"<<perm[b].get_annual()<<endl;
cout<<":YEARS OF SERVICE:"<<current_year-perm[b].get_year()<<endl;
cout<<":EMPLOYEE TYPE:"<<perm[v].get_employ_type()<<endl;
cout<<"--------------------------------------------------------------n";
}}}
system ("pause");
return 0;}
Concepts used to write a program.
1) Inheritance, for example temporary stuff
2) Arrays , for example to save data entered array used
3) Conditional statements such as If statements and switch statements
4) Loops , for example of loop used are for loops and while loop
11