Hi I need this answer quick please Question i need answered ...Write an applicat
ID: 441464 • Letter: H
Question
Hi I need this answer quick please Question i need answered ...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. Original question.. 2. 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 sets the balance to 0.0. Include a set method for the balance. Also include two abstract get methodExplanation / Answer
public abstract class Account {
int accountNumber;
double balance;
public Account( int accNumber ) {
accountNumber = accNumber;
balance = 0.0;
}
public void setBalance( double newBalance ) {
balance = newBalance;
}
abstract public double getBalance();
abstract public int getAccountNumber();
}
class Checking extends Account {
public Checking(int accountNumber)
{
super(accountNumber);
}
public int getAccountNumber()
{
return accountNumber;
}
public void getAccountInfo()
{
System.out.println( "Checking Account Information" );
System.out.println( "" + accountNumber );
System.out.println( "" + balance );
}
public double getBalance(){
return balance;
}
}
class Savings extends Account
{
private double iR;
public Savings(int accountNumber, double interestRate)
{
super(accountNumber);
iR = interestRate;
}
public int getAccountNumber()
{
return accountNumber;
}
public void getAccountInfo()
{
System.out.println( "Saving Account Information" );
System.out.println( "" + accountNumber );
System.out.println( "" + balance );
System.out.println("" + iR);
}
public double getBalance()
{
return balance;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.