Write a Java Program with methods performing following tasks…
Write a Java Program with methods performing following tasks: Main method Calls getNumOfDepts Calls genAppointmentReqs Calls allotTimeSlots Calls printDaySchedule getNumOfDepts method takes no input arguments takes number of departments in a hospital as input from the user. Verify the number is between 1 and 10, both inclusive. returns number of departments in a hospital genAppointmentReqs method takes input argument: number of departments creates an array of size = number of departments generates number of appointment requests (between 1 and 12, both inclusive) for each department through random number generation and stores in the array returns the array of appointment requests generated allotTimeSlots method takes input argument: array of appointment requests takes filename as input opens the file with filename writes a day’s appointment schedule to the file where each appointment is of one hour and the first appointment starts at 8:00. Use 24-hours time notation. Example: for number if departments = 4 and number of appointments generated as Department 1: Appointment(1) – 8 – 9; Appointment(2) – 9 – 10; Appointment(3) – 10 – 11; Department 2: Appointment(1) – 8 – 9; Appointment(2) – 9 – 10; Department 3: Appointment(1) – 8 – 9; Appointment(2) – 9 – 10; Appointment(3) – 10 – 11; Appointment(4) – 11 – 12; Appointment(5) – 12 – 13; Department 4: Appointment(1) – 8 – 9; returns the filename printDaySchedule method takes input argument: filename opens the file with filename reads day’s appointment schedule and prints it for the user to view. Example: Appointment Schedule for 2024-12-05 is as follows Department 1: Appointment(1) – 8 – 9; Appointment(2) – 9 – 10; Appointment(3) – 10 – 11; Department 2: Appointment(1) – 8 – 9; Appointment(2) – 9 – 10; Department 3: Appointment(1) – 8 – 9; Appointment(2) – 9 – 10; Appointment(3) – 10 – 11; Appointment(4) – 11 – 12; Appointment(5) – 12 – 13; Department 4: Appointment(1) – 8 – 9; returns nothing Hints: Today’s date can be obtained as: LocalDate today = LocalDate.now(); //Import required: import java.time.LocalDate; Random integer generation can be done as: int randomNum = (int)(Math.random() * (max-min+1)) + min;