Commit 3e74b493 authored by norbertdajnowski's avatar norbertdajnowski

Commit 1

parent 7805f22d
Pipeline #314 failed with stages
......@@ -6,27 +6,27 @@ public class AssessmentPartOne {
// 01 - A Gentle Start
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
if (num1<num2)
if (num1 < num2)
{
if (num3>num1)
if (num3 > num2) //num1 changed to num2 as num1 can't be the largest integer due to the last if statement
{
return num3;
}
else
{
return num1;
return num2; //num1 changed to num2 as num1 can't be the largest integer due to the if statement
}
}
else
{
if (num3>num2)
if (num3 > num1) //num1 to num2 as num2 has already been tested in the last if statement
{
return num3;
}
else
{
return num2
return num1; //added semi-colon to avoid syntax bug and changed num2 to num1 as num2 has already been checked and is not the largest
}
}
}
......@@ -42,10 +42,29 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
int sumOfSquares = 0;
int sumOfSquares = 0; //Integer to store the sum across the range
if ((start < 0) || (end < 0)) { //-1 returned if start or end are negative values to show that they can't be calculated
return sumOfSquares = -1;
}
while (start < end - 1) { //Creates a while loop that traverses the range from start to end
start++; //start incremented
sumOfSquares = sumOfSquares + start; //start added onto sumOfSquares
}
if (sumOfSquares == 0){ //if the program is not able to calculate a range then -1 is returned
sumOfSquares = -1;
}
return sumOfSquares;
return sumOfSquares; //Returns the sumOfSquares if no negative values have been found
}
}
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