Java Programming Exercise: Employee Salary Calculation, Summaries of Computer science

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

Typology: Summaries

2021/2022

Uploaded on 10/29/2022

anuj-soni
anuj-soni 🇮🇳

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Experiment Number: 1
2. Code for the program to be written:
package exp_1;
import java.util.Objects;
import java.util.Scanner;
public class Exp1 {
public static int getSalary(String[][] arr, int i) {
int DA=0;
if(Objects.equals(arr[i][3], "e")){
DA+=20000;
}
else if(Objects.equals(arr[i][3], "c")){
DA+=32000;
}
else if(Objects.equals(arr[i][3], "k")){
DA+=12000;
}
else if(Objects.equals(arr[i][3], "r")){
DA+=15000;
}
else if(Objects.equals(arr[i][3], "m")){
DA+=40000;
}
return DA;
}
public static void printJi(int empId, String[][] arr) {
int i=0;
int basic= Integer.parseInt(arr[i][5]);
Student Name:Anuj Soni UID:20BCS3023
Branch:CSE Section/Group:20BCS-KRG-WM-G1
Semester: 5TH Date of Performance:05/08/2022
Subject Name: PBL in Java lab Subject Code:20-CSP-321
pf3
pf4

Partial preview of the text

Download Java Programming Exercise: Employee Salary Calculation and more Summaries Computer science in PDF only on Docsity!

1. Experiment Number: 1

2. Code for the program to be written:

package exp_1; import java.util.Objects; import java.util.Scanner; public class Exp1 { public static int getSalary(String[][] arr, int i) { int DA=0; if(Objects.equals(arr[i][3], "e")){ DA+=20000; } else if(Objects.equals(arr[i][3], "c")){ DA+=32000; } else if(Objects.equals(arr[i][3], "k")){ DA+=12000; } else if(Objects.equals(arr[i][3], "r")){ DA+=15000; } else if(Objects.equals(arr[i][3], "m")){ DA+=40000; } return DA; } public static void printJi(int empId, String[][] arr) { int i=0; int basic= Integer.parseInt(arr[i][5]);

Student Name:Anuj Soni UID:20BCS

Branch:CSE Section/Group:20BCS-KRG-WM-G

Semester: 5TH^ Date of Performance:05/08/

Subject Name: PBL in Java lab Subject Code:20-CSP-

int HRA=Integer.parseInt(arr[i][6]); int IT=Integer.parseInt(arr[i][7]); if (empId == 1001) { i = 0; } else if (empId == 1002) { i = 1; } else if (empId == 1003) { i = 2; } else if (empId == 1004) { i = 3; } else if (empId == 1005) { i = 4; } else if (empId == 1006) { i = 5; } else if (empId == 1007) { i = 6; } else { System.out.println("employee id is wrong"); return; } String Designation = printDesg(arr, i); int DA= getSalary(arr,i); int salary= basic+HRA+DA-IT; System.out.println("Emp id Emp name Deparment Designation Salary"); System.out.println(empId +" "+ arr[i][1] +" "+ arr[i][4] +" "+ Designation + " "+salary); } public static String printDesg(String[][] arr, int i) { StringBuilder Stdesg= new StringBuilder(); Stdesg.append(arr[i][3]); String desg=Stdesg.toString(); String send="none"; switch (desg) { case "e": send="engineer"; case "c": send="Consultant"; case "k": send= "Clerk";

3. Result/Output: