Commit e399b3d7 authored by samuelboulton's avatar samuelboulton

Comments changed

parent 7805f22d
Pipeline #372 canceled with stages
...@@ -9,24 +9,24 @@ public class AssessmentPartOne { ...@@ -9,24 +9,24 @@ public class AssessmentPartOne {
if (num1<num2) if (num1<num2)
{ {
if (num3>num1) if (num3>num2) // changed num1 to num2
{ {
return num3; return num3;
} }
else else
{ {
return num1; return num2; // changed num1 to num2
} }
} }
else else
{ {
if (num3>num2) if (num3>num1) // changed num2 to num1
{ {
return num3; return num3;
} }
else else
{ {
return num2 return num1; //added ';' // changed num2 to num1
} }
} }
} }
...@@ -43,9 +43,43 @@ public class AssessmentPartOne { ...@@ -43,9 +43,43 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does // You should comment your code explaining what each part does
int sumOfSquares = 0; int sumOfSquares = 0;
int num1 = start;
int num2 = end;
// First IF statement is to make sure the first number is equal to or more than 0
if(num1 >= 0)
{
// Second IF statement is to make sure that the second number is equal to or more than 0
if(num2 >= 0)
{
// FOR loop to work out the total of the numbers inside of the 2 numbers.
for(int i = num1+1; i<num2; i++)
{
sumOfSquares = sumOfSquares + i;
}
// IF statement to filter the answers that are less that 1
if(sumOfSquares < 1)
{
// Which then returns -1 as the answer
return -1;
}
// If the sum is 1 or more then it returns sumOfSquares
else
{
return sumOfSquares; return sumOfSquares;
} }
}
// If number 2 is less than 0 it returns -1
else
{
return -1;
}
}
// If number 1 is less than 0 it returns -1
else
{
return -1;
}
}
} }
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