Commit 8898524f authored by benn.robinson's avatar benn.robinson

Update AssessmentPartOne.java

parent f874ece1
public class AssessmentPartOne {
public int biggestOfThree(int num1, int num2, int num3)
......@@ -46,21 +45,26 @@ public class AssessmentPartOne {
int sumOfSquares = 0;
int negativeAnswer = -1; //
int negativeAnswer = -1; //This is the number that will be return if range starts with a negative number
if (start < 0)
if ((start < 0) || (end < 0))
{
return negativeAnswer;
}
if (end-start == 1)
{
return negativeAnswer;
}
if (start > end) {
return negativeAnswer;
}
else
{ for (int a = start; a < end; a++)
{ for (int a = start +1; a < end; a++) { //Loop used to add all the numbers beetween the first and last int
sumOfSquares += a;
}
}
return sumOfSquares;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment