Multiple Inheritance Using Interface


import java.util.Scanner;
class A1
{
    String name;
     int regno;
    Scanner s1=new Scanner(System.in);
   public void getA()
   {
       System.out.println("Enter the Name of the Student");
        name=s1.next();
        System.out.println("Enter the Register number of the student");
        regno=s1.nextInt();
   }  
    public void displayA()
    {
        System.out.println("    MARK STATEMENT ");
        System.out.println("    ************** ");
        System.out.println("Name  :"+name+"        Regno:"+regno);
    }
}
interface B1
{
    void getB();
    void displayB();
}
class MULTI extends A1 implements  B1
{   
   int DM, CN, OS, RDBMS,total;
    double avg;
    void calc()
    {
        total=DM+CN+OS+RDBMS;
        avg=total/4;
    }

    void displayC()
    {
        System.out.println(" Average="+avg+" Total="+ total);
        System.out.println("************************************");
        if(DM>40&&CN>40&&OS>40&&RDBMS>40)
           System.out.println("Result=PASS");
        else
          System.out.println("Result=FAIL");
        System.out.println();
        System.out.println();
    }

   public void getB()
    {
        System.out.println("Enter the marks for the following Subjects");
        System.out.print("Data Mining =");
        DM=s1.nextInt();
        System.out.print("Computer Networks =");
        CN=s1.nextInt();
        System.out.print("Operating Systems =");
        OS=s1.nextInt();
        System.out.print("RDBMS =");
        RDBMS=s1.nextInt();
    }

  public void displayB()
    {
        System.out.println("************************************");
        System.out.println("Subjects                  Marks");
        System.out.println("************************************");
        System.out.println("Data Mining                 "+DM);
        System.out.println("Computer Networks           "+CN);
        System.out.println("Operating Systems           "+OS);
        System.out.println("RDBMS                       "+RDBMS);
        System.out.println("************************************");
    }   

}

public class Multipleinherit
{
    public static void main(String[] SoftwareDevelopmentLab2015)
    {
               MULTI m=new MULTI();
               m.getA();
               m.getB();
               m.calc();
               m.displayA();
               m.displayB();
               m.displayC();
}
}

OUTPUT:-


Enter the Name of the Student          
Madhu_Shieny

Enter the Register number of the student      
001

Enter the marks for the following Subjects

Data Mining =85
Computer Networks =95
Operating Systems =90
RDBMS =70



    MARK STATEMENT
    ************** ****
Name  :Madhu_Shieny          Regno: 1
************************************
Subjects                                    Marks
************************************
Data Mining                                85
Computer Networks                    95
Operating Systems                      90
RDBMS                                      70
************************************
Average=85.0                 Total=340                  
************************************
Result=PASS

No comments:

Post a Comment

Thank you for using this blog.