Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Lab – 4 Assignment:

1) Write a java class that describes an employee, such that:

An employee has a number, a name, a job title, and salary.


Employee name and number cannot be changed.

Every employee must (8 hours) this value is fixed and cannot be


changed for all employees.

Job title is fixed for each employee; i.e. once an employee is


given a job title, it cannot be changed.

Net salary of an employee is calculated as: salary – salary * tax

Tax ratio is the same for all employees.

Q. a) Determine: static, final, and static final data fields and methods.

b) Use the keyword 'this' to distinguish data fields in the class from
parameters of some constructor.
2) Write a main class that creates 5 employees, such that their data are
stored in the following arrays defined in the Main class:
String[] names = {"Ahmad", "Ali", "Amal", "Muna", "Mahmod"};
String[] jobs = {"Programmer" , "System Analyst", "Secretary",
"Sales", "Technician" };
double[] salaries = {560.5, 1000, 300, 500, 450};
For example: Ahmad is a programmer his salary is 560.5, Ali is a
system analyst his salary is 1000,…

3) Print a report for the employee list as:


Number Name Job Title Salary Tax
----------- ----------- ----------- -------- -----------

Post Lab assignment:


Add the following fields to the class: [Number of children], [experience
years], [per child allowance]
Modify the getSalary method to recalculate the salary by: GrossSalary =
salary + [number of children] * [per child allowance] + experience * [per
year allowance]
NetSalary = GrossSalary – GrossSalary*tax

You might also like