Answer to Question #245822 in Java | JSP | JSF for pinki

Question #245822

Write a java program to create an Account class and define constructors in it. Inherit Saving_Bank_Account class and Current_Bank_Account class from the Account class. Override constructors of Account class in Saving_Bank_Account and Current_Bank_Account classes. Define appropriate methods to operate these accounts. Make necessary assumptions. Give proper comment in your program to increase redability.

1
Expert's answer
2021-10-03T06:35:50-0400
public class Main
{
	public static void main(String[] args) {
		Saving_Bank_Account s=new Saving_Bank_Account(123, 10600.00);
		Current_Bank_Account c=new Current_Bank_Account(456, 2300.50);
		
		s.print2();
		c.print3();
	}
}
class Account{
    private int account_number;
    public Account(int a){
        account_number=a;
    }
    public void print1(){
        System.out.println("Account number is: "+account_number);
    }
}
class Saving_Bank_Account extends Account{
    private double amount;
    public Saving_Bank_Account(int a, double amt){
        super(a);
        amount=amt;
    } 
    public void print2(){
        print1();
        System.out.println("Amount in saving bank account_number: "+amount);
    }
}
class Current_Bank_Account extends Account{
    private double amount;
    public Current_Bank_Account(int a, double amt){
        super(a);
        amount=amt;
    } 
    public void print3(){
        print1();
        System.out.println("Amount in current bank account: "+amount);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS