Program to implement the Multiple Inheritance (Bank Interface, Customer & Account classes)

In this program, we have achieved multiple inheritance using interface. We have created an interface Bank having data members rate, no_of_years and method show( ). After that class Customer is created which has data members cust_name, cust_id and method display( ). Finally we declare the Account class having data members acc_no, acc_bal and method interest( ). In that we have extended Customerclass and implemented Bank interface as shown in program.


PROGRAM
/* Program to implement the Multiple Inheritance */

interface Bank {
 
 float rate = 12.0f;
 int no_of_years=3;
 void show();
}

class Customer {
 
 String cust_name;
 int cust_id;
 Customer(String n,int i) {
  
  cust_name = n;
  cust_id = i;
 }
 
 void display() {
  
  System.out.println("Customer Name = "+cust_name);
  System.out.println("Customer Id = "+cust_id);
 }
}

class Account  extends Customer implements Bank {
 
 int acc_no;
 float acc_bal;
 Account(String n,int b,int x,float y) {
  
  super(n,b);
  acc_no=x;
  acc_bal=y;
 }
 
 public void show() {
  
  display();
  System.out.println("Account No. = "+acc_no);
  System.out.println("Account Balance = "+acc_bal);
 }
 
 void interest() {
  
  show();
  float intr = (rate*acc_bal*no_of_years)/100;
  System.out.println("Interest = "+intr);
 }
}

public class Acct_Details {

 public static void main (String[] args) 
 {
  Account ac = new Account("Sameer",8,4052,5000);
  ac.interest();
 }
}
OUTPUT
C:\>javac Acct_Details.java
C:\>java Acct_Details
Customer Name = Sameer
Customer Id = 8
Account No. = 4052
Account Balance = 5000.0
Interest = 1800.0

Comments

  1. Good But you try give input user.

    ReplyDelete
  2. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. Walmart Customer Service

    ReplyDelete
  3. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. Syndicate bank customer care

    ReplyDelete
  4. In the event that you are in the United States, a bank in Singapore is a seaward bank to you. In this manner, the possibility of seaward banking is relative.
    chase routing number

    ReplyDelete

Post a Comment

Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

Program to draw Smiley in Applet