mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
davhojt
1cf114eb85
|
1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago |
README.md
ComputeArray
Instructions
Create a file ComputeArray.java
.
Write a function computeArray
that returns an array computed using the array of integer as parameter as followed :
- if the item is a multiple of 3, the item is multiplied by 5
- if the item is a multiple of 3 + 1 (e.g. 1, 4, 7, ...), the item is incremented by 7
- if the item is a multiple of 3 + 2 (e.g. 2, 5, 8, ...), the item stay as it is.
Expected Functions
public class ComputeArray {
public static int[] computeArray(int[] array) {
// your code here
}
}
Usage
Here is a possible ExerciseRunner.java to test your function :
public class ExerciseRunner {
public static void main(String[] args) {
int[] array = ComputeArray.computeArray(new int[]{9, 13, 8, 23, 1, 0, 89});
for (int i : array) {
System.out.print(i + " ");
}
}
}
and its output :
$ javac *.java -d build
$ java -cp build ExerciseRunner
45 20 8 23 8 0 89
$