@@ -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)//replace num1 with num2;
{
{
returnnum3;
returnnum3;
}
}
else
else
{
{
returnnum1;
returnnum2;//replace num1 with num2;
}
}
}
}
else
else
{
{
if(num3>num2)
if(num3>num1)//replaced num2 with num1;
{
{
returnnum3;
returnnum3;
}
}
else
else
{
{
returnnum2
returnnum1;//added colon here and replace num2 with num1;
}
}
}
}
}
}
...
@@ -43,7 +43,33 @@ public class AssessmentPartOne {
...
@@ -43,7 +43,33 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
// You should comment your code explaining what each part does
intsumOfSquares=0;
intsumOfSquares=0;
inta=(end-start)-1;//I used "a" for the setting length of Loop below => (Like i<a)
intb=(end-start);//I used "b" for checking difference which help me that difference should be greater then 1.
intsum=0;//I used "sum" for storing value that you can see in a loop.
if(start>=0&end>=0&b>1)//These are the conditions If "start" and "end" are greater then equal to "0" and "b" should greater then "1" then move forwared otherwise move on else statement.
{
for(inti=0;i<a;i++)//Loop
{
sum=sum+(start+1);//This step adding 1 in start's number and store in sum.
start++;//It will increment in "start" number,for moving to the next number.
sumOfSquares=sum;//Now I stored value of "sum" in "sumOfSquare" for return.
}
returnsumOfSquares;
}
else//If anything is not possible
{
sumOfSquares=-1;//it return -1 when it cannot calculate the result