Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want output like following how to fix the project? All the accounts: Account of Person: Bob with ID 0 and a balance of 1000.0

I want output like following how to fix the project?

All the accounts:

Account of Person: Bob with ID 0 and a balance of 1000.0

Account of Student: Alice at SMC with ID 1 and a balance of 500.0

High Roller Account of Person: Rich P. Person with ID 2 and a balance of

1000000.0

High Roller Account of Student: Rich S. Student at USC with ID 3 and a

balance of 100100.0

Account of Student: Rich S. Student at USC with ID 4 and a balance of

30000.0

Account of Student: Alice at SMC with ID 5 and a balance of 100.0

Account of Person: Bob with ID 6 and a balance of 5000.0

All the accounts of Alice:

Account of Student: Alice at SMC with ID 1 and a balance of 500.0

Account of Student: Alice at SMC with ID 5 and a balance of 100.0

Paying interest :

Account of Person: Bob with ID 0 and a balance of 1100.0

Account of Student: Alice at SMC with ID 1 and a balance of 550.0

High Roller Account of Person: Rich P. Person with ID 2 and a balance of

1210000.0

High Roller Account of Student: Rich S. Student at USC with ID 3 and a

balance of 121121.0

Account of Student: Rich S. Student at USC with ID 4 and a balance of

33000.0

Account of Student: Alice at SMC with ID 5 and a balance of 110.0

Account of Person: Bob with ID 6 and a balance of 5500.0

1.Main class

public class Main {

public static void main(String[] args) { Bank b = new Bank("Bank of abc"); b.setIntRate(0.1); b.setMaintFee(50); Person bob = new Person(11315,"Bob"); int bobAccId = b.openAccount(bob, 1000); Person alice = new Student(12512, "Alice", "SMC", 1234); int aliceAcctId = b.openAccount(alice, 500); Person rich = new Person(51542, "Rich P. Person"); int richAcctId = b.openAccount(rich, 1000000); Person richStudent = new Student(23814, "Rich P. Student", "USC", 1191); int richStudentAcctId = b.openAccount(richStudent, 100100); b.openAccount(richStudent, 30000); b.openAccount(alice, 100); b.openAccount(bob, 5000); System.out.println("All the accounts: "); b.printAllAccounts(); System.out.println(); System.out.println("All the accounts of Alice: "); b.printAccountsForOwner(alice); System.out.println(); System.out.println("Paying interest: "); b.payInterest(); b.printAllAccounts(); System.out.println(); System.out.println("Assessing maintenance fees: "); b.assessMaintenanceFee(); b.printAllAccounts(); System.out.println(); System.out.println("Rich P. Person buys a Ferrari, Alice wins the lottery, Rich. S. Student pays tuition ..."); b.withdraw(richAcctId, 331000); b.printAccountsForOwner(rich); b.deposit(aliceAcctId, 100000); b.printAccountsForOwner(alice); b.withdraw(richStudentAcctId, 45000); b.printAccountsForOwner(richStudent); System.out.println(); } }

2.bank

public class Bank { private BasicAccount[] accounts; private String name; private double maintFee; private double intRate; private int nextId = 0; private final double HIGH_ROLLER_LIMIT = 100000; public Bank(String name){ this.name = name; accounts = new BasicAccount[2]; } public void setIntRate(double intRate){ this.intRate = intRate; } public void setMaintFee(double maintFee){ this.maintFee = maintFee; } public int openAccount(Person owner, double balance){ return nextId++; } public double assessMaintenanceFee() { return maintFee; } public void payInterest(){ for(int i = 0;i accounts[i].balance = accounts[i].balance*intRate; } } public void deposit(int acctId, double amount) { accounts[acctId].balance += amount; } public void withdraw(int acctId, double amount) { accounts[acctId].balance -= amount; } public void printAllAccounts() {

//you code here

} public String toString(){

//you code here

} public void printAccountsForOwner(Person owner) { //you code here } private void changeAccountType(int acctId) { //you code here } }

3.basicAccount

public class BasicAccount{

protected int acctId; protected Person owner; protected String bank; protected double balance; protected double intRate; protected double mainFee;

public BasicAccount(int acctId, Person owner, String bank){ } public double deposit (double amount){ if(amount>0){ balance += amount; return balance; } else return balance; }

public double withdraw(double amount){ if(amount>0&&amount<=balance){ balance -= amount; return balance; } else if(amount>balance){ amount = balance; return balance; } else return balance; }

public double getBalance(){ return balance; } public int getAcctId(){ return acctId; } public Person getOwner(){ return owner; } public void setIntersRate(double intRate){ this.intRate = intRate; } public void setMainFee(double maintFee){ this.mainFee = mainFee; } public void addInterest(){ balance += (balance*intRate); } public double assessMaintenanceFee(){ return balance-mainFee; } public boolean equals(Object other){ return false; } }

4.Person

public class Person { protected int id; protected String name; protected String address;

public Person(int id, String name){ this.id = id; this.name = name; } public String getAddress(){ return address; } public int getId(){ return id; } public String getName(){ return name; } public String toString(){ return "Person: " + name ; } public boolean equals(Object other){ return false; } }

5.Student

public class Student extends Person { protected int sId; protected String school; public Student(int id, String name, String school, int sId ){ super(id,name); } public String getSchool(){ return school; } public int getSId(){ return sId; } public String toString(){ return "Student: "+ name +"at " + school; } }

6.StudentAccount

public class StudentAccount { protected int acctId; protected Person owner; protected String bank; protected double balance; protected double intRate; protected double mainFee;

public StudentAccount(int acctId, Person owner, String bank){ } public double deposit (double amount){ return amount; }

public double withdraw(double amount){ return amount; }

public double getBalance(){ return balance; } public int getAcctId(){ return acctId; } public Person getOwner(){ return owner; } public void setIntersRate(double intRate){ this.intRate = intRate; } public void setMainFee(double maintFee){ } public void addInterest(){ } public double assessMaintenanceFee(){ return 0; } public boolean equals(Object other){ return false; } }

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

More Books

Students also viewed these Databases questions

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago