Skip to content
Snippets Groups Projects
Commit 0cc8ff03 authored by Martin Dolmen Helmersen's avatar Martin Dolmen Helmersen
Browse files

Fix in methods for multiplication and division

parent ab6dfaf6
No related branches found
No related tags found
No related merge requests found
Pipeline #114653 passed
......@@ -15,6 +15,7 @@ public class CalculatorResource {
/**
* Method handling HTTP POST requests. The calculated answer to the expression will be sent to the client as
* plain/text.
*
* @param expression the expression to be solved as plain/text.
* @return solution to the expression as plain/text or -1 on error
*/
......@@ -43,7 +44,7 @@ public class CalculatorResource {
return result;
}
private int multiplication(String equation){
public int multiplication(String equation) {
String[] split = equation.split("*");
int number1 = Integer.parseInt(split[0]);
......@@ -52,13 +53,14 @@ public class CalculatorResource {
return number1 * number2;
}
private int division(String equation){
String[] split = equation.split("*");
public int division(String equation) {
String[] split = equation.split("/");
int number1 = Integer.parseInt(split[0]);
int number2 = Integer.parseInt(split[1]);
return number1 / number2;
}
/**
* Method used to calculate a sum expression.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment