You are on page 1of 12

Department of Computer Science CSC-210:Object-Oriented Programming

Bahria University Karachi Campus Semester 02 (SPRING 2021)

ASSIGNMENT 02
Marks: 5

Q1. Write a java code for given Program. [Marks 5]


ABC College decided to implement a management system for college where they can have the
information for all the College Employees. Employees categorized into Staff, Faculty and
Administration. Purpose of this system is to save all the information related to employees in a
system and to Display their Salaries to the accountants. System will also have a facility to set
the increments in salaries according to the performance % or attendance% of an employee.
Staff is further categorized into Office Staff and Other Staff. Faculty is further categorized into
Permanent and Visiting Faculties.
For employee information: Employee ID, Name of employee, Designation and Salary this
information would be required.
Increments in salaries would be perform with respect to following Criteria.
For Office Staff if attendance is > =70% then increment the basic salary would be 10%
For Other Staff if attendance is >= 80% then increment in Basic Salary would be of 12%
For Permanent Faculty if the performance is > =75% then increment in Basic Salary would be
15%
For Permanent Faculty if the performance is > =50% and less than 75% then increment in Basic
Salary would be 10%
For Visiting Faculty if the performance is >= 60% then increment in Basic Salary would be 5%
For Administration if the attendance is >= 75% then increment in Basic Salary would be 13%
For Administration if the attendance is >= 65% then increment in Basic Salary would be 9%
This system have option to Display the new Incremented Salaries as well.
a) Draw the UML Class Diagram with proper notations for the program Marks 1
b) Write a Java code for above scenario. Make an application class where insert the data
for at least 10 employees (of different categories) and display their Incremented
salaries as well. (Include Code and Output Screenshots as well)
Marks 3
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

c) Mention what type of inheritance is observed/used in above program. Marks 1


Part c:
Hierarchal inheritance is being used in this program. Where “Employee” is the super
class, and “Faculty”, “Staff” and “Administration” are all child classes which extends
“Employee”. Furthermore multi-level inheritance is also present here, since “Faculty”
is divided into “Permanent Faculty” and “Temporary Faculty”. While “Office Staff” and
“Other Staff” is extending “Staff”.

Part A:
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

Part B:
//Application Class
package First;

public class Application


{
public static void main (String args[])
{
//Administration
Administration x1 = new Administration ("01", "Ali", "CEO", 100000, 95);
Administration x2 = new Administration ("02", "Ahmed", "CO", 75000, 65);
System.out.println("\n==============================");
System.out.println(" Administration");
System.out.println("==============================\n");
System.out.println(x1);
System.out.println("\n" + x2);

//Staff
OfficeStaff x3 = new OfficeStaff ("01", "Hamza", "Budget Analyst", 25000, 75);
OtherStaff x4 = new OtherStaff ("02", "Raheel", "Auditor", 15000, 50);

System.out.println("\n==============================");
System.out.println(" Office Staff");
System.out.println("==============================\n");
System.out.println(x3);

System.out.println("\n==============================");
System.out.println(" Other Staff");
System.out.println("==============================\n");
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

System.out.println(x4);

//Faculty
PermanentFaculty x5 = new PermanentFaculty ("030", "Benny", "Intern", 5000,
90);
PermanentFaculty x6 = new PermanentFaculty ("031", "Blanc", "Software
Developer", 7000, 60);
TemporaryFaculty x7 = new TemporaryFaculty ("051", "Liza", "Social Media
Manager", 13000, 75);

System.out.println("\n==============================");
System.out.println(" Permanent Faculty");
System.out.println("==============================\n");
System.out.println(x5);
System.out.println("\n" + x6);

System.out.println("\n==============================");
System.out.println(" Temporary Faculty");
System.out.println("==============================\n");
System.out.println(x7);
}
}

//Employee
public class Employee
{
private String ID;
private String Name;
private String Designation;
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

protected double Salary;

Employee (String id, String name, String des, double salary)


{
ID = id;
Name = name;
Designation = des;
Salary = salary;
}

public String toString ()


{
return ("ID = " + ID + "\nName = " + Name + "\nDesignation = " + Designation +
"\nBasic Salary = " + Salary);
}
}

//Administration
public class Administration extends Employee
{
private double Attendance;
private double Increment;

Administration (String ID, String Name, String Designation, double Salary, double
Att)
{
super(ID, Name, Designation, Salary);
Attendance = Att;
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

private double TotalSalary;

public double Bonus ()


{
if (Attendance >= 75)
{
Increment = ((Salary*13)/100);
TotalSalary = Salary + Increment;
}

else if (Attendance >= 65)


{
Increment = ((Salary*9)/100);
TotalSalary = Salary + Increment;
}

else
{
TotalSalary = Salary;
}

return TotalSalary;
}

public String toString ()


{
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

return super.toString() + ("\nAttendance = " + Attendance + "\nTotal Salary = " +


Bonus());
}
}

//Staff
public class Staff extends Employee
{
protected double Attendance;
protected double Increment = 0;

Staff (String ID, String Name, String Designation, double Salary, double Att)
{
super(ID, Name, Designation, Salary);
Attendance = Att;
}
}
//OfficeStaff
public class OfficeStaff extends Staff
{
OfficeStaff (String ID, String Name, String Designation, double Salary, double
Attendance)
{
super(ID, Name, Designation, Salary, Attendance);
}

private double TotalSalary = 0;


Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

public double Bonus ()


{
if (Attendance >= 70)
{
Increment = (Salary*10)/100;
TotalSalary = Salary + Increment;
}

else
{
TotalSalary = Salary;
}

return TotalSalary;
}

public String toString ()


{
return super.toString() + ("\nAttendance = " + Attendance + "\nTotal Salary = " +
Bonus());
}
}

//OtherStaff
public class OtherStaff extends Staff
{
OtherStaff (String ID, String Name, String Designation, double Salary, double
Attendance)
{
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

super(ID, Name, Designation, Salary, Attendance);


}

private double TotalSalary = 0;

public double Bonus ()


{
if (Attendance >= 80)
{
Increment = (Salary*12)/100;
TotalSalary = Salary + Increment;
}

else
{
TotalSalary = Salary;
}

return TotalSalary;
}

public String toString ()


{
return super.toString() + ("\nAttendance = " + Attendance + "\nTotal Salary = " +
Bonus());
}}

//Faculty
public class Faculty extends Employee
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

{
protected double Performance;
protected double Increment = 0;

Faculty (String ID, String Name, String Designation, double Salary, double perform)
{
super(ID, Name, Designation, Salary);
Performance = perform;
}
}

//PermanentFaculty
public class PermanentFaculty extends Faculty
{
PermanentFaculty (String ID, String Name, String Designation, double Salary, double
Performance)
{
super(ID, Name, Designation, Salary, Performance);
}

private double TotalSalary = 0;

public double Bonus ()


{
if (Performance >= 75)
{
Increment = (Salary*15)/100;
TotalSalary = Salary + Increment;
}
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

else if (Performance >= 50 && Performance < 75)


{
Increment = (Salary*10)/100;
TotalSalary = Salary + Increment;
}

else
{
TotalSalary = Salary;
}

return TotalSalary;
}

public String toString ()


{
return super.toString() + ("\nPerformance = " + Performance + "\nTotal Salary = "
+ Bonus());
}
}

//TemporaryFaculty
public class TemporaryFaculty extends Faculty
{
TemporaryFaculty (String ID, String Name, String Designation, double Salary, double
Performance)
{
super(ID, Name, Designation, Salary, Performance);
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (SPRING 2021)

private double TotalSalary = 0;

public double Bonus ()


{
if (Performance >= 60)
{
Increment = (Salary*5)/100;
TotalSalary = Salary + Increment;
}

else
{
TotalSalary = Salary;
}

return TotalSalary;
}

public String toString ()


{
return super.toString() + ("\nPerformance = " + Performance + "\nTotal Salary = "
+ Bonus());
}
}

You might also like