// Get the checking, savings and stock accounts from the AccountData
// service component
CheckingAccount checking = accountDataService.getCheckingAccount(customerID);
System.out.println("Checking account: " + checking);
SavingsAccount savings = accountDataService.getSavingsAccount(customerID);
System.out.println("Savings account: " + savings);
StockAccount stock = accountDataService.getStockAccount(customerID);
System.out.println("Stock account: " + stock);
// Get the stock price in USD
double price = stockQuoteService.getQuote(stock.getSymbol());
System.out.println("Stock price for " + stock.getSymbol() + ": " + price);
// Convert to the configured currency
if (currency.equals("EURO")) {
// Use our fancy calculator service to convert to the target currency
price = calculatorService.multiply(price, 0.70);
System.out.println("Converted to " + currency + ": " + price);
}
// Calculate the value of the stock account
double stockValue = price * stock.getQuantity();
// Calculate the total balance of all accounts and return it
double balance = checking.getBalance() + savings.getBalance() + stockValue;
return balance;
}