if(num1>num2)// made sure num2 is greater than num1
{
{
if(num3>num1)
if(num3>num1)// made sure num1 is greater than num3
{
{
returnnum3;
returnnum3;
}
}
...
@@ -20,13 +20,13 @@ public class AssessmentPartOne {
...
@@ -20,13 +20,13 @@ public class AssessmentPartOne {
}
}
else
else
{
{
if(num3>num2)
if(num3>num2)//made sure num2 is greater than num3
{
{
returnnum3;
returnnum3;
}
}
else
else
{
{
returnnum2
returnnum2;// added semicolon to end the code
}
}
}
}
}
}
...
@@ -42,10 +42,36 @@ public class AssessmentPartOne {
...
@@ -42,10 +42,36 @@ 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;
// Setting the int data type of the sumOfNumbers setting its value to 0
intSumOfNumbers=0;
returnsumOfSquares;
//This part of the code states if the start is greater than the end value it will set the sumOfNumbers as -1 as stated in the instructions and will then return this value
//If this is not the outcome it will then continue to the else if segment of the code
if(start>end){
SumOfNumbers=-1;
returnSumOfNumbers;
}
//This segment of code is to make sure that if the code starts at 0= or ends as a 0 it will set the sumOfNumbers as -1 and return this value
//If this is not the case it will carry on to the next else if statement
elseif(start<0||end<=0){
SumOfNumbers=-1;
returnSumOfNumbers;
}
//This segment of the code states that if the start of the code plus 1 is equal to the of the code it will return the sumOfNumbers as equal -1
//If this is not the case it will then go to the while section of the code
elseif(start+1==end){
SumOfNumbers=-1;
returnSumOfNumbers;
}
//This section of the code is states while the start of the code is less than end-1 it will increment the start value. It will then start the sumOfNumbers. It then returns this value.
//This segment of the code will continue to run this section until the start value is equal to the end value of -1