Advertisement
Sajib_Ahmed

Untitled

Mar 27th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1.  
  2. package class_work;
  3.  
  4. import java.util.Scanner;
  5. public class Department {
  6. private String depName;
  7. private int depCode;
  8. Student student;
  9. Teacher teacher;
  10.  
  11. public Department(String depName, int depCode,Student student,Teacher teacher) {
  12. this.depName = depName;
  13. this.depCode = depCode;
  14. this.student=student;
  15. this.teacher=teacher;
  16. }
  17. public void displayAll()
  18. {
  19. System.out.println("Student portal :\n"+student.name+"\n"+student.age+""+student.id+"\n"+student.cgpa+"\n"+depName+"\n"+depCode+"\n");
  20. System.out.println("Teacher portal :\n"+teacher.name+"\n"+teacher.age+""+teacher.designation+"\n"+teacher.dept+"\n"+depName+"\n"+depCode+""+teacher.name+"\n");
  21.  
  22. }
  23. public static void main(String[] args)
  24.  
  25. {
  26.  
  27. Scanner Input=new Scanner(System.in);
  28. System.out.println("Enter number of student and teacher");
  29. int n=Input.nextInt();
  30. Department []obj=new Department[n];
  31. Student []obj1=new Student[n];
  32. Teacher []obj2=new Teacher[n];
  33. for(int i=0;i<n;i++){
  34. Input.nextLine();
  35. System.out.print("Student name=");
  36. String name=Input.nextLine();
  37. System.out.print("Student Age=");
  38. int age=Input.nextInt();
  39. Input.nextLine();
  40. System.out.print("Student Id=");
  41. String id=Input.nextLine();
  42. System.out.print("Student CGPA=");
  43. double cgpa= Input.nextDouble();
  44. Input.nextLine();
  45. System.out.print("Teacher name=");
  46. String name1=Input.nextLine();
  47. System.out.print("Teacher Age=");
  48. int age1=Input.nextInt();
  49. Input.nextLine();
  50. System.out.print("Teacher designation=");
  51. String designation=Input.nextLine();
  52. System.out.print("Teacher dept=");
  53. String dept=Input.nextLine();
  54. System.out.print("deptName=");
  55. String deptName = Input.next();
  56. System.out.print("deptCode=");
  57. int deptCode = Input.nextInt();
  58. obj1[i]=new Student(name,age,id,cgpa);
  59. System.out.println("Student Information\n");
  60. obj1[i].display();
  61. obj2[i]=new Teacher(name1,age1,designation,dept);
  62. System.out.println("Teacher Information\n");
  63. obj2[i].display();
  64. obj[i] = new Department(deptName,deptCode,obj1[i],obj2[i]);
  65. System.out.println("All Informatin\n");
  66. obj[i].displayAll();
  67.  
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement