Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an abstract class named Account for a bank. Include an integer field for

ID: 3622355 • Letter: C

Question

Create an abstract class named Account for a bank. Include an integer field for the account number and a double field for the account balance. Also include a constructor that requires an account number and that sets the balance to 0.0. Include a set method for the balance. Also include two abstract get methods-one for each field. Create two child classes of Account:Checking and Savings. Within the Checking class, the get method displays the String "Checking Account Information", the account number, and the balance. Within the Savings class, add a filed to hold the interest rate and require the Savings constructor to accept an argument of the value of the interest rate. The Savings get method displays the String, "Savings Account Information", the account number, the balance and the interest rate. Write an application that demonstrates you can instantiate and display both Checking and Savings objects. Save the files as Account.java, Checking.java, Savings.java and DemoAccounts.java.

Explanation / Answer

//Account class public abstract class Account { int accountnumber; double accountbalance; //constructor public Account(int accn) { accountnumber = accn; accountbalance = 0.0; } //set method public void setBalance(double bal) { accountbalance = bal; } //get methods public abstract int getaccountnumber(); public abstract double getaccountbalance(); public abstract void getdata(); } //child class Checking public class Checking extends Account { public Checking(int val) { super(val); } public void getdata() { System.out.println("Checking Account Information " + getaccountnumber() + " $" + getaccountbalance()); } public int getaccountnumber() { return accountnumber; } public double getaccountbalance() { return accountbalance; } } //child class Savings public class Savings extends Account { double intrate; public Savings(int val, double r) { super(a); intrate = r; } public void getdata() { System.out.println("Savings Account Information " + getaccountnumber() + " $" + getaccountbalance() + " Interest rate " + intrate); } public int getaccountnumber() { return accountnumber; } public double getaccountbalance() { return accountbalance; } } I hope this will helps to You !

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote