com139 software development ii crn 44949 ay 2023 2024 semester 2 modul
Search for question
Question
COM139: Software Development II
CRN: 44949 (AY 2023/2024 Semester 2)
Module Coordinator: Dr Dermot Kerr
Assessment Overview and Schedule:
This module is 100% coursework. The assessment schedule is as follows:
This coursework is Class Exercise 1.
Description
Implement your own solutions to programming problems in the following pages. There are 8
questions in total worth 20 marks.
You can develop your solutions using IntelliJ project provided which contains the unit tests
required to ensure your solution is correct or you can build your own project in your preferred
IDE using the method headers provided below. Alternatively, you can code directly in
codeboard.io when you have access.
Submission of solution
Note that we will use the codeboard.io environment is used to accept your solutions with
code functionality tested using a series of unit tests. You need to make sure to click the submit
button when your solution is finalised. Class Exercise 1 (20 marks)
1. Complete the method int array2DMax(int[][] a) that returns the maximum value in
the 2d array a and complete the method int array2DMin(int[] [] a) that returns the
minimum value in the 2d array a. Your solution should work for any size of 2d array.
(4 marks - 2 marks for each correctly functioning method).
For example, the following array has a maximum value of 8 and a minimum value of -7.
1 83
-752
4 02
inum public static int array2DMax(int[][] a) { }
public static int array2DMin(int[] [] a) { }
2. Complete the method int rowSum(int[][] a, int x) that returns the sum of the
elements in Row x of the 2d array a and complete the method int colSum(int[][] a,
int y) that returns the sum of the elements in Column y of the 2d array a. Your solution
should work for any size of 2d array.
(4 marks - 2 marks for each correctly functioning method).
For example, the following array has a sum of 12 for row 0 and a sum of 7 for column 2.
1
83
-752
4 02
public static int rowSum(int[][] a, int x) { }
public static int colSum(int[] [] a, int y) { }
3. Complete the method int[] allRowSums(int[] [] a) that calculates the row sum for
every row and returns each of the values in an array. Index i of the return array contains the
sum of elements in row i. Your solution should work for any size of 2d array.
(2 marks for correctly functioning method).
For example, for the following array the result should be [12,0,6]
1 8 3
-752
4 02
public static int[] allRowSums ( int [][] a) { } 4. Complete the method int[] allColSums (int[ ] [ ] a) that calculates the col sum for
every column and returns each of the values in an array. Index i of the return array contains
the sum of elements in col i. Your solution should work for any size of 2d array.
(2 marks for correctly functioning method).
For example, for the following array the result should be [-2,13,7]
1 83
-752
4 02
public static int[] allColSums(int[][] a) { }
5. Complete the method boolean is RowMagic(int[] [] a) that checks if the array a is
row-magic (this means that every row has the same row sum). Your solution should work for
any size of 2d array.
(2 marks for correctly functioning method).
For example, the following array is row magic as all rows sum to 6.
1
23
-1 5 2
4 02
public static boolean isRowMagic(int[][] a){ }
6. Complete the method public static boolean isColMagic(int[][] a) that checks if the array a
is column-magic (this means that every column has the same column sum). Your solution
should work for any size of 2d array.
(2 marks for correctly functioning method).
For example, the following array is column magic as all columns sum to 4.
1-14 10
35 0-6
public static boolean isColMagic(int[][] a){ } 7. Complete the method boolean isRowEvenInc(int[][] a) that checks if the row sum of even
numbers in array a are increasing in size. Your solution should work for any size of 2d array.
(2 marks for correctly functioning method).
For example, the following array row sum evens [-6, 2, 6] are increasing in value so the
result should be true.
1 -4-2
-72-3
4 0 2
public static boolean isRowEvenInc(int[][] a){ }
8. Complete the method boolean isColOddDec(int[] [] a) that checks if the column sum of
odd numbers in array a are decreasing in size. Your solution should work for any size of 2d
array. (2 marks for correctly functioning method).
For example, the following array column sum odds [8, 0, -1, -4] are decreasing in value so
the result should be true.
34-1-1
50-2-3
public static boolean isColOddDec(int[][] a){ }
Total marks available: 20