File tree 2 files changed +40
-43
lines changed
2 files changed +40
-43
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package easy ;
2
+
3
+ /**
4
+ * Have the function SimpleEvens(num) check whether
5
+ * every single number in passed in parameter is even.
6
+ * If so, return the string true, otherwise return the string false.
7
+ * For example: if num is 4602225 your program should
8
+ * return the string false because 5 is not an even number.
9
+ */
10
+ public class SimpleEvens {
11
+
12
+ /**
13
+ * Simple Evens function.
14
+ *
15
+ * @param num input number
16
+ * @return "true" if a number is even
17
+ */
18
+ private static String simpleEvens (Integer num ) {
19
+ String [] digits = num .toString ().split ("" );
20
+ for (String digit : digits ) {
21
+ if (Integer .parseInt (digit ) % 2 != 0 ) {
22
+ return "false" ;
23
+ }
24
+ }
25
+ return "true" ;
26
+ }
27
+
28
+ /**
29
+ * Entry point.
30
+ *
31
+ * @param args command line arguments
32
+ */
33
+ public static void main (String [] args ) {
34
+ String result1 = simpleEvens (222252 );
35
+ System .out .println (result1 );
36
+ String result2 = simpleEvens (228 );
37
+ System .out .println (result2 );
38
+ }
39
+
40
+ }
You can’t perform that action at this time.
0 commit comments