Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

java applications

The document outlines an experiment for a Java application that retrieves and displays employee details based on an input employee ID. It includes the aim, objectives, implementation code, and expected learning outcomes related to employee data management. Key features include salary calculation and error handling for invalid employee IDs.

Uploaded by

leofncdays
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

java applications

The document outlines an experiment for a Java application that retrieves and displays employee details based on an input employee ID. It includes the aim, objectives, implementation code, and expected learning outcomes related to employee data management. Key features include salary calculation and error handling for invalid employee IDs.

Uploaded by

leofncdays
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


Experiment 1
Name:Vineet Karan UID:22BCS16616
Branch: BE-CSE Section/Group:IOT 607/B
Semester:6th Date: 21-01-2015
Subject Name: Project Based Learning Subject Code: 22CSH-359
in Java with Lab

1. Aim: Given the following table containing information about employees


of an organization, develop a small java application, which accepts
employee id from the command prompt and displays the following
details as output:
Emp No Emp Name Department Designation and Salary
You may assume that the array is initialized with the following details:

Salary is calculated as Basic+HRA+DA-IT. (DA details are given in the


Designation table)

Designation details :
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Use Switch-Case to print Designation in the output and to find the value of
DA for a particular employee.

2. Objective:
i. Assuming that your class name is Project1, and you execute your code as
java Project1 1003, it should display the following output : Emp No. Emp
Name Department Designation Salary
1003 Rahul Acct Clerk 29000 ii.
java Project1 123
There is no employee with empid : 123

3. Implementation/Code:

import java.util.Scanner;
public class Project1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] empNo = {"1001", "1002", "1003", "1004", "1005", "1006",
"1007"};
String[] empName = {"Ashish", "Sushma", "Rahul", "Chahat",
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


"Ranjan", "Suman", "Tanmay"};
String[] joinDate = {"01/04/2009", "23/08/2012", "12/11/2008",
"29/01/2013", "16/07/2005", "01/01/2000", "12/06/2006"};
String[] desigCode = {"e", "c", "k", "r", "m", "e", "c"};
String[] dept = {"R&D", "PM", "Acct", "Front Desk", "Engg",
"Manufacturing", "PM"};
int[] basic = {20000, 30000, 10000, 12000, 50000, 23000, 29000};
int[] hra = {8000, 12000, 8000, 6000, 20000, 9000, 12000};
int[] it = {3000, 9000, 1000, 2000, 20000, 4400, 10000};
System.out.print("Enter Employee ID: ");
Int EmpId = sc.nextInt();
int index = -1;
for (int i = 0; i < empNo.length; i++) {
if (empNo[i].equals(inputEmpId)) {
index = i;
break;
}
}
if (index == -1) {
System.out.println("There is no employee with empid: " +
inputEmpId);
} else {
int da;
String designation;
switch (desigCode[index]) {
case "e":
designation = "Engineer";
da = 20000;
break;
case "c":
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
designation = "Consultant";
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


da = 32000;
break;
case "k":
designation = "Clerk";
da = 12000;
break;
case "r":
designation = "Receptionist";
da = 15000;
break;
case "m":
designation = "Manager";
da = 40000;
break;
default:
designation = "Unknown";
da = 0;
}
int salary = basic[index] + hra[index] + da - it[index];
System.out.println("Emp No Emp Name Department
Designation Salary");
System.out.println(empNo[index] + " " + empName[index] + " "
+
dept[index] + " " + designation + " " + salary);
}
sc.close();
}
}
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


4. Output:

5. Learning Outcomes:
 Understand how to map employee details (like designation codes to roles)
using efficient logic and structures.
 Learn to identify and address input mismatches or invalid entries through
proper validation and error messages.
 Gain skills in presenting data in a well-structured and readable format for
better user understanding.

You might also like