Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Make the Account class as an abstract class. Define an abstract method printAccountInfo() which should be implemented by the sub classes. This method should

JAVA

Make the Account class as an abstract class. Define an abstract method printAccountInfo() which should be implemented by the sub classes. This method should display the type of account along with the account details.

public class Account { protected int accountNumber; protected double balance;

// Constructor public Account(int a) { balance = 0.0; accountNumber = a; }

public void deposit(double amount) { if (amount > 0) balance += amount; else System.err.println("Account.deposit(...): " + "cannot deposit negative amount."); }

public void withdraw(double amount) { if (amount > 0) if (balance - amount >= 0) balance -= amount; else System.err.println("Account.withdraw(...): " + "cannot withdraw more than your balance."); else System.err.println("Account.withdraw(...): " + "cannot withdraw negative amount."); }

public double getbalance() { return balance; }

public double getAccountNumber() { return accountNumber; }

public void display() { System.out.println("Account " + accountNumber + " : " + "Balance = " + balance); }

}

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_2

Step: 3

blur-text-image_3

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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

internationalization of business?

Answered: 1 week ago