Commit 4c5c3216 authored by samuelboulton's avatar samuelboulton

finished

parent 33dec52f
......@@ -3,9 +3,10 @@ public class AssessmentPartOne {
public int biggestOfThree(int num1, int num2, int num3)
{
// 01 - A Gentle Start
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
/* 01 - A Gentle Start
Debug this method so it passes the unit test.
Add comments beside any changes you make
*/
if (num1<num2)
{
......@@ -33,48 +34,49 @@ public class AssessmentPartOne {
public int sumNumbersBetween(int start, int end)
{
// 02 - Adding Across A Range
// Complete this method so that it adds together all
// the integers between start and end, but not including
// start or end
// This method should only deal with 0 and positive integers
// This method should return -1 if it cannot calculate the result
// You should comment your code explaining what each part does
/* 02 - Adding Across A Range
Complete this method so that it adds together all
the integers between start and end, but not including
start or end
This method should only deal with 0 and positive integers
This method should return -1 if it cannot calculate the result
You should comment your code explaining what each part does
*/
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
// 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
// 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 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 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
// if the sum is 1 or more then it returns sumOfSquares
else
{
return sumOfSquares;
}
}
// If number 2 is less than 0 it returns -1
// if number 2 is less than 0 it returns -1
else
{
return -1;
}
}
// If number 1 is less than 0 it returns -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