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

Java 1

Uploaded by

Amit Kumar
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)
28 views

Java 1

Uploaded by

Amit Kumar
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/ 3

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 1.1
Student Name: Amit Kumar UID: 21BCS7024
Branch: CSE Section/Group: CC-640-B
Semester: 6 Date of Performance:15/01/24
Subject Name: JAVA Subject Code: 21CSH-319

1. Aim: Create a application to save the employee information using arrays.

2. Objective: 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 details.

3. Algorithm/Code:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int[] empId = {1001, 1002, 1003, 1004, 1005, 1006, 1007};
String[] empName = {"Ashish", "Sushma", "Rahul", "Chahat", "Ranjan", "Suman",
"Tanmay"};

String[] joinDate = {"01-04-2009", "23-08-2012", "03-03-2021", "04-04-2021",


"05-05-2021", "06-07-2021","25-12-2021"};

String[] depName = {"Managment", "Accounting", "R&D ", "Marketing", "IT


department", "Sales ", "FrontDesk"};
int[] basic = {41000, 51000, 61000, 71000, 98000, 20000, 4000};
int[] hra = {1000, 2000, 3000, 4000, 5000, 2900, 8000};
int[] it = {5500, 4400, 3300, 2200, 1100, 5500, 1100};
char[] desCode = {'m', 'k', 'e', 'c', 's', 'a', 'r'};
int[] da = new int[7];
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

String[] des = new String[7];

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


if (desCode[i] == 'm') {
des[i] = "Manager";
da[i] = 10000;
}
}
int[] sal = new int[7];
for (int i = 0; i < 7; i++) {
sal[i] = basic[i] + hra[i] + da[i] - it[i];
}
System.out.print("Enter the Emp ID whose Salary is to be Calculated: ");
Scanner s = new Scanner(System.in);
int x = s.nextInt();

boolean found = false;


System.out.println("\nEmp ID\t\tEmp
Name\tDepartment\t\tDesignation\t\tSalary");
for (int i = 0; i < 7; i++) {
if (x == empId[i]) {
System.out.println(empId[i] + "\t\t" + empName[i] + "\t\t" + depName[i] +
"\t\t" + des[i] + "\t\t " + sal[i]);
found = true;
break; // Break out of the loop once the employee is found
}
}
if (!found) {
System.out.println("Employee with ID " + x + " not found.");
}
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

4. Output:

You might also like