-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx10.java
More file actions
25 lines (19 loc) · 812 Bytes
/
Ex10.java
File metadata and controls
25 lines (19 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package java_exercises_1_sda;
//Właśnie się dowiedziałeś, że istnieje operator %. Napisz funkcję, która będzie sprawdzała,
// czy napisana w poprzednim zadaniu funkcja zwraca dokładnie takie same wyniki jak ten
// operator. Przetestuj dla różnych przypadków.
public class Ex10 {
public static void main(String[] args) {
System.out.println("Ex9: ");
int[] testTab = {1, 5, 7, 122, 45};
System.out.println("Assert true: " + Ex10.testMyModulo(testTab, 3));
}
public static boolean testMyModulo(int[] testNumb, int mod) {
for (int number : testNumb) {
int originRest = number % mod;
int myRest = Ex9.myModulo(number, mod);
if (originRest != myRest) return false;
}
return true;
}
}