Skip to content

Commit 72cb957

Browse files
committed
Fix style and bug in printEvens
1 parent c7133a3 commit 72cb957

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.codefortomorrow.intermediate.chapter11.practice;
22

33
public class Average {
4-
54
/**
65
* Difficulty: 1
76
*
@@ -11,6 +10,6 @@ public class Average {
1110
* @return average
1211
*/
1312
public static double average(double a, double b) {
14-
return 0.0; //TODO: Fix!
13+
return 0.0; // TODO: Fix!
1514
}
1615
}

src/com/codefortomorrow/intermediate/chapter11/practice/PrintEvens.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ public class PrintEvens {
55
* Difficulty: 1
66
*
77
* Print the first n even integers
8+
* (consider 0 an even number)
89
* @param n number of even integers to print
910
*/
1011
public static void printEvens(int n) {
11-
12+
// write code here
1213
}
1314
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.codefortomorrow.intermediate.chapter11.solutions;
22

33
public class Average {
4-
54
/**
65
* Difficulty: 1
76
*
@@ -11,8 +10,6 @@ public class Average {
1110
* @return average
1211
*/
1312
public static double average(double a, double b) {
14-
return (a + b)/2;
13+
return (a + b) / 2;
1514
}
16-
17-
1815
}

src/com/codefortomorrow/intermediate/chapter11/solutions/PrintEvens.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public class PrintEvens {
55
* Difficulty: 2
66
*
77
* Print the first n even integers
8+
* (consider 0 an even number)
89
* @param n number of even integers to print
910
*/
1011
public static void printEvens(int n) {
@@ -13,7 +14,7 @@ public static void printEvens(int n) {
1314
while (evens < n) {
1415
if (i % 2 == 0) {
1516
System.out.print(i + " ");
16-
n++;
17+
evens++;
1718
}
1819
i++;
1920
}

0 commit comments

Comments
 (0)