consider the class Account has accountNumber (String) and ( double) balance 1- w
ID: 3838024 • Letter: C
Question
consider the class Account has accountNumber (String) and ( double) balance
1- write the defintion of class Account.
2- write the class CheckingAccount that extends from the class Account. CheckingAccount has the following attributes:int checksUsed;
int trans;
int monthly;
int funds;
boolean hasSup;
3- write consturcor with the seven parameters that intializes all attirbues inclduing the parent.
4- write a SavingAccount that inherits from the class Account. the class SavingAccount has double annual and
double insurance;
5-write a class Bank that has a name (String) and a listOfAccounts which is an ArrayList of Account object.
6-write a constructor for a class Bank that takes only one parameter m, and initlaizes the bank name to m, then creates a listOfAccounts as a new(empty) ArrayList of the object Account.
7- in the class Bank, write a method addCheckingAccounts (String fileName) that takes file name as a parameter and reads from that file a list of Account contanting an accountNumber, a balance, the number of cheks used ( checksUsed) the number of transctions (trans) monthly fees(monthly), inusfficient funds fees (funds), has suplimetarty ( hasSup) yes or no. then creates an object of type Account for each entry in the file, then adds ut ti the listOfAccounts in the Bank class. this is my code so far
public class Account {
String accountNumber;
private double balance;
public Account() {
this.accountNumber = "";
this.balance = 0;
}
public Account(String accountNumber, double balance) {
this.accountNumber = accountNumber;
this.balance = balance;
}
public String getAccountNumber() {
return accountNumber;
}
public double getBalance() {
return balance;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public void setBalance(double balance) {
this.balance = balance;
}
public class CheckingAccount extends Account {
private int checksUsed;
private int trans;
private int monthly;
private int funds;
private boolean hasSup;
public CheckingAccount(String accountNumber ,double balance, int checksUsed, int trans, int monthly, int funds, boolean hasSup) {
super(accountNumber, balance);
this.checksUsed = checksUsed;
this.trans = trans;
this.monthly = monthly;
this.funds = funds;
this.hasSup = hasSup;
}
public class SavingAccount extends Account {
private double annual;
private double insurance;
public void setAnnual(double annual) {
this.annual = annual;
}
public void setInsurance(double insurance) {
this.insurance = insurance;
}
public double getAnnual() {
return annual;
}
public double getInsurance() {
return insurance;
}
}
public class Bank extends Account {
public Bank() {
}
private String name;
ArrayList<Account> listOfAccounts = new ArrayList();
public Bank(String m) {
ArrayList<Account> lifstOfAccounts = new ArrayList();
m = name;
}
HELP PLEASE
Explanation / Answer
import java.util.*;
import java.io.*;
public class Account
{
public String accountNumber;
public double balance;
}
CheckingAccount extends Account
{
public int trans;
public int monthly;
public int funds;
public boolean hasSup;
public CheckingAccount()
{
accountNumber="";
balance=0.0;
trans=0;
monthly=0;
funds=0;
hasSup=false;
}
}
class SavingAccount extends Account
{
public double annual and
public double insurance;
}
class Bank
{
String name;
ArrayList<Account> obj;
public Bank(String m)
{
name=m;
}
public listOfAccounts()
{
obj=new ArrayList<Account>();
obj.add("100120011");
obj.add(100000.0);
obj.add("100120022");
obj.add(200000.0);
obj.add("100120033");
obj.add(300000.0);
obj.add("100120044");
obj.add(400000.0);
obj.add("100120066");
obj.add(600000.0);
}
public addCheckingAccounts (String fileName)
{
InputStream istream;
OutputStream ostream;
int c;
final int EOF = -1;
ostream = System.out;
try {
File inputFile = new File(fileName);
istream = new FileInputStream(inputFile);
try {
while ((c = istream.read()) != EOF)
ostream.write(c);
}
catch (IOException e)
{
System.out.println("Error: " + e.getMessage());
}
finally
{
try {
istream.close();
ostream.close();
} catch (IOException e) {
System.out.println("File did not close");
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
System.exit(1);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.