0% found this document useful (0 votes)
29 views

Assignment 1 Problem

The 'Employee' class in the Java program encapsulates employee details such as ID, work experience, salary, and monthly scores, with methods for checking bonus eligibility, incrementing salary, and calculating average scores. The 'SingleEmployeeTest' class allows for the creation of a single Employee object based on user input and performs operations like displaying employee information and calculating bonuses and increments. An example input and output demonstrate the functionality, and a modification is suggested to enable the creation of multiple employees using an array and a loop.

Uploaded by

nazhatarannum090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Assignment 1 Problem

The 'Employee' class in the Java program encapsulates employee details such as ID, work experience, salary, and monthly scores, with methods for checking bonus eligibility, incrementing salary, and calculating average scores. The 'SingleEmployeeTest' class allows for the creation of a single Employee object based on user input and performs operations like displaying employee information and calculating bonuses and increments. An example input and output demonstrate the functionality, and a modification is suggested to enable the creation of multiple employees using an array and a loop.

Uploaded by

nazhatarannum090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Question 1: Describe the “Employee” class and its usage in the “SingleEmployeeTest” class in a Java

program. The Employee class stores employee information like ID , work experience as years , salary,
and monthly scores, and provides methods for bonus eligibility, salary increment, and average score
calculation.

• The Employee class has the following attributes:

• int id to store the employee's ID.

• int workExperience to store the employee's work experience in years.

• double salary to store the employee's salary.

• int[] score to store an array of monthly scores.

• The Employee class also has the following methods:

• bonusEligibility(): Checks if the employee is eligible for a bonus based on work


experience and salary. If the employee work experience is more than 10 years or
monthly salary is less than 10000, employee would be eligible for bonus

• increment(int inc): Increments the employee's salary by a given percentage. The


increment would 20% of his/her monthly salary

• averageScore(): Calculates and prints the average score of the employee based on the
monthly scores.

Also provide an example of input and the expected output when using the SingleEmployeeTest” class

In the SingleEmployeeTest” class, user input is used to create 1 Employee object and perform
operations.

Example Input:

Enter ID: 1

Enter WorkExperience: 11

Enter Monthly Salary: 300

How many months you want to calculate score: 3

Enter 0 th month score: 1

Enter 1 th month score: 2

Enter 2 th month score: 3

Example Output:

Employee id= 1

workExperience in years= 11
monthly salary= 300.0

Eligible for bonus

incremented salary: 360.0

average score=2.0

Question 2: Now modify the “SingleEmployeeTest” class in a way so that now you can create “n”
number of employess and display their information.

Hint: use a loop to take information for multiple employees. You can achieve this by using an array to
store the employee objects and a loop to iterate over them

You might also like