Multiple Inheritance and Packages

  1. package pack2;
  2. public class student
  3. {
  4. public int rno, m1, m2, m3, tot;
  5. public String name, result;
  6. public void getdata(int x1,String x2, int x3, int x4, int x5)
  7.  
  8.  
  9. {
  10.  
  11. rno = x1;
  12. name = x2;
  13. m1 = x3;
  14. m2 = x4;
  15. m3 = x5;
  16. tot = m1 + m2 + m3;
  17. if((m1>=50)&&(m2>=50)&&(m3>=50))
  18. result ="pass";
  19. else
  20.  
  21. result = "fail";
  22.  
  23. }
  24.  
  25. public void putdata()
  26.  
  27.  
  28. {
  29.  
  30. System.out.println("Rollno: "+rno);
  31. System.out.println("Name: "+name);
  32. System.out.println("mark1: "+m1);
  33. System.out.println("mark2: "+m2);
  34. System.out.println("mark3: "+m3);
  35. System.out.println("Total : "+tot);
  36. System.out.println("Result: "+result);
  37. }
  38. }
  1. package pack1;
  2. import java.io.*;
  3. public interface sports
  4.  
  5. {
  6. public void setsum()throws IOException;
  7.  
  8. }
  1. import pack1.*;
  2. import pack2.*;
  3. import java.io.*;
  4. class result extends student implements sports
  5. {
  6. int sm;
  7. String sname;
  8. public void setsum() throws IOException
  9. {
  10. InputStreamReader r = new InputStreamReader(System.in);
  11. BufferedReader b = new BufferedReader(r);
  12. System.out.println("Enter sports name");
  13. sname = b.readLine();
  14. System.out.println("Enter sports mark");
  15. String s = b.readLine();
  16. sm = Integer.parseInt(s);
  17. System.out.println(sm);
  18. }
  19. public void display() throws IOException
  20. {
  21. setsum();
  22. putdata();
  23. System.out.println("Sports name :"+sname);
  24. System.out.println("Sports Mark :"+sm);
  25.  
  26. }
  27. }
  28.  
  29. public class mult
  30. {
  31. public static void main(String args[]) throws IOException
  32.  
  33.  
  34. {
  35. result res = new result();
  36. res.getdata(101,"Karthik",98,90,95);
  37. System.out.println("student details");
  38. res.display();
  39. }
  40. }