0% found this document useful (0 votes)
63 views6 pages

Exp-1.1 19BCS1431

The document describes a student experiment to develop a Java application that accepts an employee ID from the command line and displays employee information. The application defines an Employee class with fields for employee details. An array of Employee objects is initialized with sample data. The code searches the array for the employee with the given ID and displays their name, department, designation, and calculated salary. The student learned to implement classes and use array data structures.
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)
63 views6 pages

Exp-1.1 19BCS1431

The document describes a student experiment to develop a Java application that accepts an employee ID from the command line and displays employee information. The application defines an Employee class with fields for employee details. An array of Employee objects is initialized with sample data. The code searches the array for the employee with the given ID and displays their name, department, designation, and calculated salary. The student learned to implement classes and use array data structures.
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/ 6

Experiment 1.

1
Student Name: M.Sudharshan UID: 19BCS1431
Branch: CSE Section/Group: NTPP_CI_1A
Semester: 6th Date of Performance: 12/2/2022
Subject Name: PBLJ LAB Subject Code: CSP-358

1. Aim/Overview of the practical:

Given the table containing information about employees of an organization, develop a


small java application, which accepts employee id from the command prompt and displays
the output.

2. Task to be done/ Which logistics used:


Repl.it

3. Steps for experiment/practical/Code:


class Employee {

int EmpNo;

String EmpName;

String JoinDate;

char DesigCode;

String Dept;

int Basic;

int HRA;

int IT;
Employee(int no, String name, String date, char code, String dep, int bas, int hra, int it) {

EmpNo = no;

EmpName = name;

JoinDate = date;

DesigCode = code;

Dept = dep;

Basic = bas;

HRA = hra;

IT = it;

}
public class Project1 {

public static void main(String[] args) {

Employee[] employees = {

new Employee(1001, "Ashish", "01/04/2009", 'e', "R&D", 20000, 8000, 3000), new

Employee(1002, "Sushma", "23/08/2012", 'c', "PM", 30000, 12000, 9000), new Employee(1003,

"Rahul", "12/11/2008", 'k', "Acct", 10000, 8000, 1000), new Employee(1004, "Chahat",

"29/01/2013", 'r', "Front Desk", 12000, 6000, 2000), new Employee(1005, "Ranjan", "16/07/2005",

'm', "Engg", 50000, 20000, 20000), new Employee(1006, "Suman", "1/1/2000", 'e',

"Manufacturing", 23000, 9000, 4400), new Employee(1007, "Tanmay", "12/06/2006", 'c', "PM",

29000, 12000, 10000), };


try {

int no = Integer.parseInt(args[0]);

for (Employee emp : employees) {

if (emp.EmpNo == no) {

int DA = 0;

String designation = "";

switch (emp.DesigCode) {

case 'e':

DA = 20000;

designation = "Engineer";

break;

case 'c':

DA = 32000;

designation = "Consultant";

break;

case 'k':

DA = 12000;

designation = "Clerk";

break;

case 'r':

DA = 15000;

designation = "Receptionist";
break;

case 'm':

DA = 40000;

designation = "Manager";

break;

int salary = emp.Basic + emp.HRA + DA - emp.IT;

System.out.printf("%7s %15s %15s %15s %15s\n", "Emp No.", "Emp Name", "Department",
"Designation", "Salary");

System.out.printf("%7s %15s %15s %15s %15s\n", emp.EmpNo, emp.EmpName, emp.Dept,


designation, salary);

System.exit(0);

System.out.println("There is no employee with empid : " + no);

} catch (Exception e) {

System.out.println("Something went wrong...");

} finally{

System.out.println("\nCode by 19BCS1431\n");

} }

}
4. Result/Output/Writing Summary:
5. Learning Outcomes

I learned -

1. How to implement classes

2. Basics of array data structure

You might also like