Java Write an application that stores at least five differen
Java:
Write an application that stores at least five different department and supervisor names in a two-dimensional array. Allow the user to enter a department name (such as “Marketing”) and display the corresponding supervisor’s name. If the department does not exist, display an error message.
Save the file as Departments.java.
Solution
import java.util.Scanner;
public class Depatments {
public static void main(String[] args) {
       boolean found=false;
        String arr[][]={{\"Marketing\",\"Joey\"},{\"Accounting\",\"Phoebe\"},{\"HR\",\"Rachel\"},{\"Development\",\"Chandler\"},{\"Purchasing\",\"Monica\"}};
         Scanner scanner = new Scanner(System.in);
        System.out.println(\"Enter a Department Name\");
        System.out.flush();
        String department = scanner.nextLine();
        for(int i=0;i<5;i++){
            if(arr[i][0].equals(department)){
                System.out.println(\"Supervisor for the department is: \"+ arr[i][1]);
                found=true;
                break;
            }
        }
        if(!found){
            System.out.println(\"Sorry. Department details not found for the entered department\");
       }
    }
}
Hi, you may change the values for department or supervisor name in the array. If you have any doubt in the code, please feel free to ask.

