Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class depositsAndWithdrawlFiles{
- public static void main(String[]args) throws IOException {
- SavingsAccount account1 = new SavingsAccount(500);
- account1.setAnnualInterestRate(12);
- double totalInterestEarned = 0;
- File depositFile = new File("deposits.txt");
- File withdrawlsFile = new File("withdrawls.txt");
- Scanner inputFile = new Scanner(depositFile);
- while(inputFile.hasNext() ) {
- account1.deposit(inputFile.nextDouble() );
- }
- inputFile.close();
- inputFile = new Scanner(withdrawlsFile);
- while(inputFile.hasNext() ) {
- account1.withdraw(inputFile.nextDouble() );
- }
- inputFile.close();
- account1.addMonthlyInterest();
- System.out.println("Ending balance: $%,.f\nTotal interest earned: $%,.f", account1.getBalance(), totalInterestEarned);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement