-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckAttendanceController.java
More file actions
51 lines (43 loc) · 1.38 KB
/
CheckAttendanceController.java
File metadata and controls
51 lines (43 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class CheckAttendanceController {
@FXML
private Label absent;
@FXML
private Label percentage;
@FXML
private Label present;
@FXML
private Label total;
@FXML
public void initialize() {
Student s1 = (Student) LearningSystem.activeUser;
int nPresent, nAbsent, nTotal;
double nPercentage = 0;
nPresent = s1.getNoOfPresents();
nAbsent = s1.getNoOfAbsents();
nTotal = nAbsent + nPresent;
try {
nPercentage = nPresent / nTotal * 100;
} catch (ArithmeticException e) {
System.err.println("Division by zero.");
}
absent.setText(String.format("%d", nAbsent));
present.setText(String.format("%d", nPresent));
total.setText(String.format("%d", nTotal));
percentage.setText(String.format("%.2f", nPercentage));
}
@FXML
void homeAct(ActionEvent event) throws Exception {
Stage stage = (Stage) present.getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("StudentDashboard.fxml"));
Scene scene = new Scene(root);
stage.setTitle("LMS");
stage.setScene(scene);
}
}