Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using your completed Assignment 7, change the existing code that prints the details of an account and direct the output to a file in addition

Using your completed Assignment 7, change the existing code that prints the details of an account and direct the output to a file in addition to the screen. You can decide which parts of your account should be printed. Assignment 7: ACCOUNT CLASS: public class Account { public String accountNo; public double accountBal; public String accountName; public Account () {} public Account(String acct, String accountNo) { this.accountNo = accountNo; this.accountName = null; this.accountBal = 0; } public Account(String acct, String name, double balance) { super(); this.accountNo = acct; this.accountName = name; this.accountBal = balance; } public void setBalance(double balance) { this.accountBal = balance; } public void setName(String name) { this.accountName = name; } public String getacct() { return accountName; } public String getname() { return accountName; } public double balance() { return accountBal; } // equals public boolean equals(Account obj) { Account other = (Account) obj; if (Double.doubleToLongBits(accountBal) != Double.doubleToLongBits(other.accountBal)) return false; if (accountName == null) { if (other.accountName != null) return false; } else if (!accountName.equals(other.accountName)) return false; if (accountName == null) { if (other.accountName != null) return false; } else if (!accountName.equals(other.accountName)) return false; return true; } } SAVINGS CLASS: public class Savings extends Account { double interestRate; Savings() {} public Savings(double interestRate) { this.interestRate=interestRate; } public Savings(String accountNo, String accountName, double accountBal,double interestRate) { super(accountNo, accountName, accountBal); this.interestRate=interestRate; } public double getInterestRate() { return interestRate; } public void setInterestRate(double interestRate) { this.interestRate = interestRate; } public String print() { return " Savings Account Information: Account Number: "+super.accountNo+ " Balanace : "+super.accountBal+" Account Holder: "+super.accountName+ " Interset Rate: " +this.calcInterest()%.2f; } public double calcInterest() { return ((this.interestRate * (super.accountBal))/12); } } CHECKINGS CLASS: public class Checking extends Account { int checkNumber; Checking() {} public Checking(int checkNumber) { this.checkNumber=checkNumber; } public Checking(String accountNo, String accountName, double accountBal, int checkNumber) { super(accountNo, accountName, accountBal); this.checkNumber = checkNumber; } public int getCheckNumber() { return checkNumber; } public void setCheckNumber(int checkNumber) { this.checkNumber = checkNumber; } public String print() { return " Checking Account Information: "+super.accountNo+ " Current Check Number: "+this.checkNumber+" Account Holder: "+super.accountNo+ " Balance: " +super.accountBal; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions