-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReport.java
More file actions
28 lines (22 loc) · 862 Bytes
/
Copy pathReport.java
File metadata and controls
28 lines (22 loc) · 862 Bytes
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
import java.time.LocalDate;
import java.util.List;
public class Report {
public static String generateReport(List<Task> tasks) {
int total = tasks.size();
int completed = 0;
long totalTime = 0;
for (Task t : tasks) {
if (t.getStatus().equalsIgnoreCase("Completed"))
completed++;
totalTime += t.getTimeSpent();
}
double score = total == 0 ? 0 :
((double) completed / total) * 100;
return "------ Productivity Report ------\n\n" +
"Total Tasks: " + total + "\n" +
"Completed Tasks: " + completed + "\n" +
"Total Time Spent (ms): " + totalTime + "\n" +
"Productivity Score: " + score + "%\n" +
"Report Date: " + LocalDate.now();
}
}