Lectures Covered : 27-30
The objective of this assignment is to enhance knowledge of Java Programming:
1. It will increase learning of Java data types, classes concepts
2. Hand on experience of arrays
3. Students will be able to implement Inheritance and Over riding
Please read the following instructions carefully before solving & submitting the assignment:
1. The assignment will not be accepted after due date.
2. Zero marks will be awarded to the assignment that does not open or the file is
3. The assignment file must be MS Word (.doc) file format; Assignment will not be
accepted in any other format.
4. Zero marks will be awarded to the assignment if copied (from other student or copied
from handouts or internet).
5. Zero marks will be awarded to the assignment if the Student ID is not mentioned in
the assignment file.
Note: All types of plagiarism are strictly prohibited. Copy cases will be awarded
Question No 1:
Suppose a textile company “Grace Textile” human resource (HR) department. It has total 80
employees in 3 different branches. Employees are of 3 categories: Internees, Contract and Permanent
employees. Internees have internship of 6 months with fixed salary i.e, 20 thousand. Salaries are
calculated on basis of grades. Both contract and permanent employees have different pay scales.
Permanent employees also got benefits of pension and gratuity .Contract employees get monthly
salary and an annual additional bonus.
You are required to write a Java program comprising :
• Three Classes Employee, Contract Employee, Permanent Employee
• Employee class will have basic attributes of “Employee Id”, CNIC, Name, Grade, Salary and
Category (Internee, Contract, and Permanent). Use “I” for internee, “C” for “Contract” and
“P” for permanent
• CNIC will be of format 123-456-789
• Contract Employee class will have attributes/data members of Employee class and an
additional member “Bonus”
• Permanent Employee class will have attributes of Employee class along with 2 additional
attributes “Gratuity” and “Pension”
• Use proper data types for all data members
• Write display message of base class and derived classes which will print Emp Id of respective
• Write a function for Contract Employee Class that will calculate bonus. Roll number will be
stored in an array. Roll number will be your own vu id only digits (8 digits excluding first 2
characters). E.g, If your Roll number is BC12345678, 12345678 will be stored in array. Add
all 8 digits and name it “sum”. Calculate bonus with formula: (sum*1000)/2; Print value of
Steps to Compile /Execute Java Program:
Open following link :
Here you can compile and execute your Java Code with(JDK 1.8.0)*.
1. Paste/replace your code
2. “Execute” program
3. Take screen shot of code plus result
4. Copy it in .doc file
5. Your assignment should be in .doc or .docx format
Hints: You will use inheritance and overriding for display function.