File tree Expand file tree Collapse file tree 4 files changed +6
-8
lines changed
src/com/codefortomorrow/intermediate/chapter11 Expand file tree Collapse file tree 4 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 1
1
package com .codefortomorrow .intermediate .chapter11 .practice ;
2
2
3
3
public class Average {
4
-
5
4
/**
6
5
* Difficulty: 1
7
6
*
@@ -11,6 +10,6 @@ public class Average {
11
10
* @return average
12
11
*/
13
12
public static double average (double a , double b ) {
14
- return 0.0 ; //TODO: Fix!
13
+ return 0.0 ; // TODO: Fix!
15
14
}
16
15
}
Original file line number Diff line number Diff line change @@ -5,9 +5,10 @@ public class PrintEvens {
5
5
* Difficulty: 1
6
6
*
7
7
* Print the first n even integers
8
+ * (consider 0 an even number)
8
9
* @param n number of even integers to print
9
10
*/
10
11
public static void printEvens (int n ) {
11
-
12
+ // write code here
12
13
}
13
14
}
Original file line number Diff line number Diff line change 1
1
package com .codefortomorrow .intermediate .chapter11 .solutions ;
2
2
3
3
public class Average {
4
-
5
4
/**
6
5
* Difficulty: 1
7
6
*
@@ -11,8 +10,6 @@ public class Average {
11
10
* @return average
12
11
*/
13
12
public static double average (double a , double b ) {
14
- return (a + b )/ 2 ;
13
+ return (a + b ) / 2 ;
15
14
}
16
-
17
-
18
15
}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ public class PrintEvens {
5
5
* Difficulty: 2
6
6
*
7
7
* Print the first n even integers
8
+ * (consider 0 an even number)
8
9
* @param n number of even integers to print
9
10
*/
10
11
public static void printEvens (int n ) {
@@ -13,7 +14,7 @@ public static void printEvens(int n) {
13
14
while (evens < n ) {
14
15
if (i % 2 == 0 ) {
15
16
System .out .print (i + " " );
16
- n ++;
17
+ evens ++;
17
18
}
18
19
i ++;
19
20
}
You can’t perform that action at this time.
0 commit comments