0% found this document useful (0 votes)
47 views4 pages

Java 1.1 Sumit

hciudsv ifhiusbd iugfcudgs

Uploaded by

sumitsingla271
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)
47 views4 pages

Java 1.1 Sumit

hciudsv ifhiusbd iugfcudgs

Uploaded by

sumitsingla271
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/ 4

Experiment- 1.

Student Name: Sumit UID: 21BCS10075


Branch: BE-CSE Section/Group: KRG_SC_1
Semester: 6th Date of Performance: 18/01/2023
Subject Name: Project Based Learning in Java Subject Code: 21CSH-319

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

2. Objective:
• To learn about arrays in java.
• To learn about usage of loops and switch statements.

3. Script and Output:


import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Count of employees ");
int count=sc.nextInt();
int empid[]=new int[count];
String name[]=new String[count];
String date[]=new String[count];
String dcode[]=new String[count];
String Dept[]=new String[count];
int basic[]=new int[count];
int HRA[]=new int[count];
int IT[]=new int[count];
int DA[]=new int[count];
System.out.println("Employee number: ");
for(int i=0;i<count;i++){
empid[i]=sc.nextInt();
}
System.out.println("Employee names: ");
for(int i=0;i<count;i++){
name[i]=sc.next();
}
System.out.println("Enter joining date of employees: ");
for(int i=0;i<count;i++){
date[i]=sc.next();
}
System.out.println("Enter Design Code ");
for(int i=0;i<count;i++){
dcode[i]=sc.next();
switch(dcode[i])
{
case "e":
DA[i]=20000;
break;
case "c":
DA[i]=32000;
break;
case "k":
DA[i]=12000;
break;
case "r":
DA[i]=15000;
break;
case "m":
DA[i]=40000;
break;
default:
System.out.println("User entered invalid department");
return;
}
}
System.out.println("Enter Department name: ");
for(int i=0;i<count;i++){
Dept[i]=sc.next();
}
System.out.println("Enter Basic of Employee: ");
for(int i=0;i<count;i++){
basic[i]=sc.nextInt();
}
System.out.println("Enter HRA: ");
for(int i=0;i<count;i++){
HRA[i]=sc.nextInt();
}
System.out.println("Enter IT: ");
for(int i=0;i<count;i++){
IT[i]=sc.nextInt();
}

System.out.println("Enter employee id to calculate salary:");


int idd=sc.nextInt();
for(int i=0;i<count;i++){
if(empid[i]==idd)
{
int Salary=basic[i]+HRA[i]+IT[i]+DA[i];
System.out.println("Name of the employee is: "+ name[i]+ "\nSalary of employee is: " + Salary);
return;
}
else
{
continue;
}
}
System.out.println("You entered invalid Employee number");
}
}
Output:

You might also like