Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

L5 (0.6 marks) Add/Update AddStudent method such that: accepts two input values represent the students name and age if the name and/or age are not

L5 (0.6 marks)

  • Add/UpdateAddStudentmethod such that:
    • accepts two input values represent the studentsnameandage
    • if thenameand/orageare not valid, return false
    • if the input name already exists in the array liststudents, return false.
      • Hint:Use the appropriate loop structure
    • If the studentnameandageare valid and the name does not exist in the ArrayListstudents, then:
      • Create a new instance of classStudent
      • pass the input parametersnameandageto the constructor of classStudent
      • add the new instance to the ArrayListstudents
  • Add/UpdateAddFacultymethod such that:
    • accepts one input value represents the name of the faculties
    • if thenameis not valid, return false
    • if the input name already exists in the array listfaculties, return false.
      • Hint:Use the appropriate loop structure
    • If the facultynameis valid and the name does not exist in the ArrayListfaculties, then:
      • Create a new instance of classFaculty
      • pass the input parameternameto the constructor of classFaculty
      • add the new instance to the ArrayListfaculties

L6 (0.6 marks)

  • Add/UpdateAddEnrollmentmethod such that:
    • It accepts two input parameters: thestudentNameandfacultyName.
    • if the array liststudentsdoes not contain a student with the namestudentName, print an error message and return false.
      • if thestudentNamecan be found, set a reference to its object
        • Student selectedStudent = students.get(i);
    • if the array listfacultiesdoes not contain a faculty with the namefacultyName, print an error message and return false.
      • if thefacultyNamecan be found, set a reference to its object
        • Faculty selectedFaculty = faculties.get(i);
    • Create a new instance of theEnrollmentclass, add it to theenrollmentsarraylist, and return true
  1. Enrollment newEnrol=new Enrollment(selectedStudent, selectedFaculty);
  2. enrollments.add(newEnrol);

USE INTELLIJ JAVA TO ANSWER

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

Where do you see yourself in 5/10 years?

Answered: 1 week ago