You are on page 1of 2

Programming Fundamentals I 18-19 – Laboratory Sessions

Lab exam - Group A2


Description:
Implement a Java program to work with multi-dimensional arrays by using modular
programming in an appropriate way, with the following behavior:
- A welcome message will be displayed on the screen (e.g. “Welcome to this
fancy application to work with arrays”), followed by a menu with these options,
which are always available to the user except when “Exit” is selected:
o 1.) Sort array (decreasing order)
o 2.) Remove duplicates
o 3.) Remove and sort
o 4.) Sum of odd numbers in 2D array
o 5.) Exit
- When “Exit” is selected, the program ends.
- Out of range options will not have any effect on the program running (in the
main menu).
- When a result is shown (according to the options), the program will return to the
main menu.
1.) Sort array (decreasing order): Given a one-dimensional array of integers (values
previously read from the keyboard), show the original array followed by the same array
but sorted (in decreasing order).
e.g.: original array: [7, 3, -5, 6, 12, -2]
sorted array: [12, 7, 6, 3, -2, -5]

2.) Remove duplicates: Given a one-dimensional array of integers (values previously


read from the keyboard), remove all duplicate value per each number and show the
original array followed by the same array without duplicates.
e.g.: original array: [7, 3, -5, 7, 11, 7]
result array: [7, 3, -5, 11]

3.) Remove and sort: Given a one-dimensional array of integers (values previously
read from the keyboard), remove all duplicate values of each number, sort the array in
decreasing order, and show the original array followed by the result array.
e.g.: original array: [7, 3, -5, 7, 11, 7]
result array: [11, 7, 3, -5]

4.) Sum of odd numbers in 2D array: Given an “NxM“ array of integers (values
previously read from the keyboard), show the original array followed by the sum of all
odd values.
3 − 5 7 11
e.g.: original array: [2 0 4 − 2]
7 1 6 22
Total sum of odd numbers: 24
The implemented program (*.java) must be uploaded to “Campus Virtual” at the end of
the class time. A template called “LabExamA2.java” is available at “Campus Virtual” to
help with your coding.
Notes:
- Use of modular programming will be a mandatory aspect.
- Show the output for each option in a fancy way.
- Control of errors in keyboard inputs and out of range options through condition
statements.
- Use of class notes is not allowed
- This task can be made in pairs.
It will be scored:
- Code is easily readable (cleaning, correct indentation, appropriate names for
variables, correct statements and loops, comments).
- Use of methods (mandatory)
- Program runs/works properly for each option (1, 2, 3, 4, and 5).
- Program builds/compiles with no errors (mandatory).

You might also like