0% found this document useful (0 votes)
12 views14 pages

PSOOPL Submission Template

The document outlines a programming assignment involving the creation of an Employee management system with classes for Employee and SalariedEmployee, including methods for inputting employee data and determining the highest salary. It also describes a recruitment test system with a Recruitment class and a Testing subclass that evaluates candidates based on predefined questions. The main method in both programs facilitates user interaction and displays results.

Uploaded by

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

PSOOPL Submission Template

The document outlines a programming assignment involving the creation of an Employee management system with classes for Employee and SalariedEmployee, including methods for inputting employee data and determining the highest salary. It also describes a recruitment test system with a Recruitment class and a Testing subclass that evaluates candidates based on predefined questions. The main method in both programs facilitates user interaction and displays results.

Uploaded by

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

Name: Nisarg Anand Chhoda

UID: 2024200020

Experiment No. 1

AIM:

Program 1

PROBLEM STATE Define parent class "Employee" that has 3 private attributes
MENT :
String name, String id, int age.

Employee has constructor with 3 arguments that set value of name, id, ag
e. It also has getter and setter methods for all 3 private attributes.

Class "SalariedEmployee" is a sub class of Employee and has 1 private


attribute empSalary.

"SalariedEmployee" can be permanent or on contract and has constructor


SalariedEmployee(String name, String id, int age, double empSalary) to set
the values.

constructor SalariedEmployee must call the superclass constructor to set n


ame, id, age and call setter method to set the salary.

Employee salary is empSalary + 2000(allowance) if he is a permanent emp


loyee else Employee salary is empSalary (no allowance).

Accept the details of 5 salaried employees and print details of the employe
e with highest salary. Hint: Use array of objects

Create class Tester with main method


PROGRAM: import java.util.Scanner;

class Employee {
private String name, id;
private int age;

Employee(String name, String id, int age) {


this.name = name;
this.id = id;
this.age = age;
}
String getName() {
return name;
}
void setName(String name) {
this.name = name;
}
String getId() {
return id;
}
void setId(String id) {
this.id = id;
}
int getAge() {
return age;
}
void setAge(int age) {
this.age = age;
}
}

class SalariedEmployee extends Employee {


private int empSalary;

SalariedEmployee(String name, String id, int age, int empSalary, int


empType) {
super(name, id, age);
setEmpSalary(empType == 1 ? empSalary + 2000 : empSalary);
}
int getEmpSalary() {
return empSalary;
}

void setEmpSalary(int empSalary) {


this.empSalary = empSalary;
}

void displayDetails() {
System.out.println("Name: " + getName());
System.out.println("ID: " + getId());
System.out.println("Age: " + getAge());
System.out.println("Salary: " + getEmpSalary());
}
}

class Tester {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
SalariedEmployee[] employees = new SalariedEmployee[5];

for (int i = 0; i < 5; i++) {


System.out.println("Enter Employee " + (i + 1) + " Details:");
System.out.print("Name: ");
String name = scanner.nextLine();
System.out.print("ID: ");
String id = scanner.nextLine();
System.out.print("Age: ");
int age = scanner.nextInt();
System.out.print("Base Salary: ");
int empSalary = scanner.nextInt();
System.out.print("Enter 1 for Permanent, 0 for Contract: ");
int empType = scanner.nextInt();
scanner.nextLine();
employees[i] = new SalariedEmployee(name, id, age, empSalary,
empType);
}

SalariedEmployee highestSalaryEmp = employees[0];


for (int i = 1; i < employees.length; i++) {
if (employees[i].getEmpSalary() > highestSalaryEmp.getEmpSal
ary()) {
highestSalaryEmp = employees[i];
}
}

System.out.println("\nHighest Salary Employee:");


highestSalaryEmp.displayDetails();
}
}

RESULT:
Program 2

PROBLEM STATE Mr. Abhishek Bachan is an H.R. Manager of “ABCL Technologie


MENT : s” At the beginning of the new year he anticipated that the co
mpany will need 30 new additional persons to fill up different v
acancies in software team. He gave an advertisement in the ne
wspaper inviting applications for filling up different vacant post
s. As many as 120

applications were received. The same were scrutinized and the


y were given four tests. There are 4 sections and

each section has 2 questions each.

Create class Recruitment that prints if the person has passed(g


reater than 60%) or failed the test.

Create sub class Testing that generates the marks percentage


based on his answers in test.

class Testing has methods takeTest and generateResult(). Des


ign objective answers for following questions and conduct test
and generate result whether candidate passed or failed.

Create class Tester with main method

The objective of the first test was to find out how much interes
t the applicant takes in his work.

Questions asked

1.What is the vision of the company?

2.How long will you stay in this role?

The objective of the second test was to find out ‘specialization’


of the applicant in any particular area.

Questions asked
1.What is final method in Java?

2.What is the latest version of Java?

Third test aimed at making sure whether the applicant was cap
able of learning through training or not.

Questions asked

1.What did you learn about Java in last job?

2.What do you wish to learn?

The purpose of the fourth test was to find out how much capab
ility a person has to mix-up with other persons, and whether h
e can influence other persons and get influenced by them.

Questions asked

1.What makes a team successful?

2.Do you work faster in team or as individual?

PROGRAM:
import java.util.*;

class Recruitment {

int[] scr = {3, 3, 1, 1, 3, 3, 3, 3};

int[] ans = new int[8];

void section_1() {

Scanner scan = new Scanner(System.in);

System.out.println("Section 1.");
System.out.println("-------------------------------------------------------");

System.out.println("First Question: ");

System.out.println("What is the vision of the company?");

System.out.println("Options: ");

System.out.println("1. To increase the revenue");

System.out.println("2. To develop the best products");

System.out.println("3. To make new breakthroughs");

System.out.println("4. To reach the most number of people");

ans[0] = scan.nextInt();

System.out.println("-------------------------------------------------------");

System.out.println("Second Question: ");

System.out.println("How long will you stay in this role?");

System.out.println("1. 1 year");

System.out.println("2. 2 years");

System.out.println("3. 3 years");

System.out.println("4. 5+ years");

ans[1] = scan.nextInt();

System.out.println("-------------------------------------------------------");

void section_2() {

Scanner scan = new Scanner(System.in);

System.out.println("Section 2.");
System.out.println("First Question: ");

System.out.println("What is final method in Java?");

System.out.println("Options: ");

System.out.println("1. a method that cannot be overridden by subclass


es");

System.out.println("2. Main Method");

System.out.println("3. Sub class method");

System.out.println("4. Parent class method");

ans[2] = scan.nextInt();

System.out.println("-------------------------------------------------------");

System.out.println("Second Question: ");

System.out.println("What is the latest version of Java?");

System.out.println("1. 23");

System.out.println("2. 21");

System.out.println("3. 22");

System.out.println("4. 24");

ans[3] = scan.nextInt();

System.out.println("-------------------------------------------------------");

// method for section 3 of the test

void section_3() {

Scanner scan = new Scanner(System.in);


System.out.println("Section 3.");

System.out.println("First Question: ");

System.out.println("What did you learn about Java in last job?");

System.out.println("Options: ");

System.out.println("1. It's versatility");

System.out.println("2. Adaptability");

System.out.println("3. Uses in AI/ML");

System.out.println("4. Time complexity");

ans[4] = scan.nextInt(); // store answer for question 1

System.out.println("-------------------------------------------------------");

System.out.println("Second Question: ");

System.out.println("What do you wish to learn?");

System.out.println("1. Enhance my skills in teamwork.");

System.out.println("2. Gain experience in project management");

System.out.println("3. Develop expertise in industry trends.");

System.out.println("4. Learn effective communication strategies her


e.");

ans[5] = scan.nextInt();

System.out.println("-------------------------------------------------------");

void section_4() {

Scanner scan = new Scanner(System.in);


System.out.println("Section 4.");

System.out.println("First Question: ");

System.out.println("What makes a team successful?");

System.out.println("Options: ");

System.out.println("1. Trust and Respect");

System.out.println("2. Effective Communication");

System.out.println("3. Clear Goals and Objectives");

System.out.println("4. Collaboration and Cooperation");

ans[6] = scan.nextInt();

System.out.println("-------------------------------------------------------");

System.out.println("Second Question: ");

System.out.println("Do you work faster in team or as individual?");

System.out.println("1. I prefer working individually for focus.");

System.out.println("2. It depends on the task complexity.");

System.out.println("3. I find a balance between both.");

System.out.println("4. I thrive in a team environment.");

ans[7] = scan.nextInt();

System.out.println("-------------------------------------------------------");

class Testing extends Recruitment {

void takeTest() {
super.section_1();

super.section_2();

super.section_3();

super.section_4();

void genResult() {

int c = 0;

for (int i = 0; i < 8; i++) {

if (ans[i] == scr[i]) {

c++;

double res = ((c / 8.0) * 100);

if (res >= 60) {

System.out.println("Congratulations! You have passed our recruitmen


t test.");

} else {

System.out.println("Unfortunately you did not qualify for our intervie


w.");

class Tester {
public static void main(String[] args) {

Testing test = new Testing();

Scanner scan = new Scanner(System.in);

System.out.println("Welcome to the recruitment test for ABCL Techno


logies!");

System.out.println("Are you ready to take the test?");

System.out.println("Let's Start!");

System.out.println("-------------------------------------------------------");

test.takeTest();

test.genResult();

}
RESULT:
Program 3

PROBLEM STATE
MENT:

PROGRAM:

RESULT:

Program 4

PROBLEM STATE
MENT:

PROGRAM:

RESULT:

CONCLUSION:

You might also like