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 int field for the

ID: 3653898 • Letter: C

Question

Create an abstract class named Account for a bank. Include an int field for the account number and a double field for the account balance. Create abstract accessors and mutators (getters and setters) for both fields. Remember: abstract methods don't have a body! Also include a constructor that requires an account number and that sets the balance to 0.0. Create two child classes of Account: Checking and Savings. Within the Checking class, the toString method displays the String "Checking Account Information", the account number, and the balance. Within the Savings class, add a field to hold the interest rate and require the Savings constructor to accept an argument for the value of the interest rate. Create an accessor and mutator for the interest rate field. The Savings toString 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. You are expected to use all rules that demonstrate compliance with naming conventions, constructors, instantiation, etc. Save your files as Account.java, Checking.java, Savings.java, and DemoAccounts.java.Can anyone fix the below codes. public abstract class account { int accountNumber; double accountbalance; public Account(int acctNum) { accountNumber = acctNum; accountbalance = 0.0; } public abstract void setAccountBalance(double acctbal) { //System.out.println("Saving Account Information. Account balance: " + accountBalance); } public abstract double getAccountBalance() { //System.out.println("Saving Account Information. Account balance: " + accountBalance); } public abstract void setAccountNumber(int acctNum) { // System.out.println("Saving Account Information. Account number: " + accountNumber); } public abstract int getAccountNumber() { // System.out.println("Saving Account Information. Account number: " + accountNumber); } /** * Displays the interest rate. */ public abstract void setInterestRate(double intRate) { //System.out.println("Saving Account Information. Interest rate: " + interestRate); } public abstract double getInterestRate() { //System.out.println("Saving Account Information. Interest rate: " + interestRate); } } public class Checking extends Account { private static final String TEMPLATE = "Invoice Number: %d%n" + "Sales Amount: $%.3f%n"+ "Sales Tax: $%.3f%n"; public Checking(int acctNum) { super(acctNum); setaccountbalance(acctbal); } public void setAccountBalance( double acctbal) { accountbalance=acctbal; // System.out.println("Checking Account Information. Account balance: " + accountBalance); } public double getAccountBalance( ) { return accountbalance ; } public void setAccountNumber(int acctNum) { accountNumber=acctNum; } public int getAccountNumber( ) { return accountNumber; } public String toString() { String s = String.format(TEMPLATE, getAccountNumber(), getAccountBalancnce()); System.out.println(s); return s; } } public class Savings extends Account { /** * The interest rate. */ double interestRate; private static final String TEMPLATE = "Invoice Number: %d%n" + "Sales Amount: $%.3f%n"+ "Sales Tax: $%.3f%n"; /** * Initializes the savings with the provided account number and interest * rate. The savings account balance is set to 0. * * @param accountNumber * @param interestRate */ public Savings(int acctNum,double acctbal, double intRate) { super(accountNumber); setaccountbalance(acctbal); interestRate = intRate; } public void setAccountBalance(double acctbalance) { //System.out.println("Saving Account Information. Account balance: " + accountBalance); accountbalance=acctbal; } public double getAccountBalance(){ return accountbalance; } public void setAccountNumber(int acctNum) { accountNumber=acctNum;//System.out.println("Saving Account Information. Account number: " + accountNumber); } public int getAccountNumber(){ return accountNumber; } /** * Displays the interest rate. */ public void setInterestRate(double intRate) { interestRate=intRate; //System.out.println("Saving Account Information. Interest rate: " + interestRate); } public double getInterestRate(){ return interestRate;} public String toString() { String s = String.format(TEMPLATE, getAccountNumber(), getAccountBalance(),getInterestRate()); System.out.println(s); return s; } } public class DemoAccounts { public static void main(String args[]) { Savings savings = new Savings(457246, 2.1); savings.setaccountbalance(9300); //savings.displayAccountNumber(); //savings.displayAccountBalance(); //savings.displayInterestRate(); System.out.println(savings); Checking checking = new Checking(9124123); checking.setaccountbalance(7000); System.out.println(checking); //checking.displayAccountNumber(); //checking.displayAccountBalance(); } }

Explanation / Answer

public abstract class Account {
private int accountNumber;
private double balance;

public Account( int accNumber ) {
accountNumber = accNumber;
balance = 0.0;
}

public void setBalance( double newBalance ) {
balance = newBalance;
}

public int getAccountNumber(); // the abstract get method for the account balance
// how do you think you'd declare the get method for the balance?
}

public class Checking extends Account {

public int getAccoutNumber() {
System.out.println( "Checking Account Information" );
System.out.println( "" + accountNumber );
System.out.println( "" + balance );

}

That's a HUGE leg up on this assignment. I'm sure you can do the rest. Good luck!

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