Commit 5dad9686 authored by joseph.jackson1's avatar joseph.jackson1

Delete AssessmentPartOne.java

parent 3623904b
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
if (num1<num2)
{
if (num3>num1 && num3>num2) // added a check if num3 is also bigger than num2
{
return num3;
}
else if(num2>num3)
{
return num2;
} // added an else if checking if num2 is bigger than num3
// no need to check if bigger than num1 as won't enter if statement if not
else
{
return num1;
}
}
else
{
if (num3>num2 && num3>num1) // added a check if num3 is also bigger than num1
{
return num3;
}
else if( num2>num3)
{
return num2; // added a semicolon
} // added an else if to check if num2 is bigger than num3
else
{
return num1;
}
}
}
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
int sumOfSquares = 0;
if ((start <end) && (start+1 <end)) { // checks if the starting number is smaller than the ending number, and if there are numbers between the start and end number
for ( int i=start+1;i<end;i++) { // goes through each number between, but not including, the start and end numbers
if(sumOfSquares>=0) { // check that the sum isn't smaller than 0 currently
sumOfSquares = sumOfSquares + i; // adds the current number to the sum
}
else {
sumOfSquares = -1; // sets the sum to -1 if the sum is smaller than 0
}
}
}
else {
sumOfSquares = -1;// sets the sum to -1 if it cannot calculate the result
}
return sumOfSquares;
}
}
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