SD2720 Module 2 Using Operators, Arrays, and Constructs
Lab 2.2 Using Multidimensional Array and Loops
In this lab, you will complete three tasks related to multidimensional arrays and loops. The tasks performed in this lab will help you understand how to program common array operations and simplify programming by using loops.
Task 1
Write a Java program with the following functionalities:
• It should use a one-dimensional array.
• It should enable the user to search for an element in the array.
• If the element is found, it should display the number of occurrences.
• If the element is not found, an error message should be displayed.
Task 2
Create a Java application that stores and maintains the employee details, including employee ID, employee name, department, designation, marital status, and date of marriage, in a multidimensional array. The application should have the following functionalities:
• When the user selects the enter data option, the inputs should be accepted.
• Date of marriage should be accepted only if the employee’ marital status is entered as “married.”
• When the user selects the view data option, all the employee details should be displayed.
• When the user selects the exit option, the application should terminate.
For Task 3
• Did you write Java codes to display all three patterns?
• Did you write the code using loops?
• Are the codes readable and documented?