Create a parent class “Account” with three variables num, title and bal with two functions withdraw and
deposit. Create a child class “SavingAccount” with a function calculateProfit (that applies 7.5% profit on current balance). Finally create the class “TestApp” that creates the object of Saving account and call withdraw, deposit functions and public data members of Account class. Override withdraw function in SavingAccount to deduct Rs. 250 if the balance after withdrawal of amount is less than 10000.
public class TestApp {
public static void main(String[] args) {
// imple..
}
}
class SavingAccount {
private double currentBalance;
SavingAccount(double currentBalance) {
this.currentBalance = currentBalance;
}
public double calculateProfit() {
this.currentBalance = (1-0.75) * currentBalance;
}
}
Comments
Leave a comment