-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinanceManager.java
More file actions
30 lines (25 loc) · 961 Bytes
/
FinanceManager.java
File metadata and controls
30 lines (25 loc) · 961 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
29
30
// FinanceManager.java
public class FinanceManager {
private User user;
// Constructor
public FinanceManager(User user) {
this.user = user;
}
// Method to add income
public void addIncome(double amount) {
user.setTotalIncome(user.getTotalIncome() + amount);
}
// Method to deduct expenses
public void deductExpenses(double amount) {
user.setTotalExpenses(user.getTotalExpenses() + amount);
}
// Method to calculate remaining balance
public double calculateRemainingBalance() {
return user.getTotalIncome() - user.getTotalExpenses();
}
// Method to calculate future expenses and remaining balance
public double calculateFutureExpensesAndBalance(double futureExpenses) {
double totalExpensesIncludingFuture = user.getTotalExpenses() + futureExpenses;
return user.getTotalIncome() - totalExpensesIncludingFuture;
}
}