Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void update(String text) {
} else if (operation.equals("/")) {
displayValue = operationDiv(internalValue, displayValue);
} else if (operation.equals("%")){
displayValue = operationPercent(displayValue);
displayValue = operationPercent(internalValue, displayValue);
} else if (operation.equals("±")){
displayValue = operationInverse(displayValue);
} else if (operation.equals("C")){
Expand Down Expand Up @@ -126,7 +126,9 @@ public double operationDiv(double rhs, double lhs) {
return rhs;
}

public double operationPercent(double value) { return 0.1; }
public double operationPercent(double lhs, double rhs) {
return lhs%rhs;
}

public double operationInverse(double value) { return -42.0; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void shouldDivTwoByOne(){
public void shouldInverse() { assertEquals(-42.0, calc.operationInverse(42.0), 0.1); }

@Test
public void shouldPercent() { assertEquals(0.1, calc.operationPercent(10.0), 0.1); }
public void shouldPercent() { assertEquals(5, calc.operationPercent(15, 10), 0.1); }

@Test
public void shouldClear() { assertEquals(0.0, calc.operationClear(), 0.1);}
Expand Down