Upload files to "OOP/Java/Lab/Week13"
This commit is contained in:
parent
0909e7c1ae
commit
8fbdd81a2b
5 changed files with 402 additions and 0 deletions
95
OOP/Java/Lab/Week13/EmployeeMoney.java
Normal file
95
OOP/Java/Lab/Week13/EmployeeMoney.java
Normal file
|
@ -0,0 +1,95 @@
|
|||
import javafx.application.Application;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
class Employee {
|
||||
|
||||
private String name;
|
||||
private String empID;
|
||||
private String designation;
|
||||
private double basicPay;
|
||||
private double DA;
|
||||
private double HRA;
|
||||
private double PF;
|
||||
private double LIC;
|
||||
private double netSalary;
|
||||
|
||||
public Employee(
|
||||
String name,
|
||||
String empID,
|
||||
String designation,
|
||||
double basicPay,
|
||||
double LIC
|
||||
) {
|
||||
this.name = name;
|
||||
this.empID = empID;
|
||||
this.designation = designation;
|
||||
this.basicPay = basicPay;
|
||||
this.LIC = LIC;
|
||||
|
||||
this.DA = 0.4 * basicPay;
|
||||
this.HRA = 0.15 * basicPay;
|
||||
this.PF = 0.12 * basicPay;
|
||||
|
||||
this.netSalary = basicPay + DA + HRA - PF - LIC;
|
||||
}
|
||||
|
||||
public String getEmployeeInfo() {
|
||||
return String.format(
|
||||
"""
|
||||
Employee Details:
|
||||
Name: %s
|
||||
Employee ID: %s
|
||||
Designation: %s
|
||||
Basic Pay: $%.2f
|
||||
DA: $%.2f
|
||||
HRA: $%.2f
|
||||
PF: $%.2f
|
||||
LIC: $%.2f
|
||||
Net Salary: $%.2f
|
||||
""",
|
||||
name,
|
||||
empID,
|
||||
designation,
|
||||
basicPay,
|
||||
DA,
|
||||
HRA,
|
||||
PF,
|
||||
LIC,
|
||||
netSalary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public class EmployeeInfoApp extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
Employee emp = new Employee(
|
||||
"John Doe",
|
||||
"E123",
|
||||
"Software Engineer",
|
||||
50000,
|
||||
2000
|
||||
);
|
||||
|
||||
Label infoLabel = new Label(emp.getEmployeeInfo());
|
||||
infoLabel.setStyle("-fx-font-family: monospace;");
|
||||
|
||||
VBox root = new VBox(10);
|
||||
root.setPadding(new Insets(10));
|
||||
root.getChildren().add(infoLabel);
|
||||
|
||||
Scene scene = new Scene(root, 300, 400);
|
||||
primaryStage.setTitle("Employee Information");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue