Commit a22e0791 authored by Thundy's avatar Thundy

completed Programming 01 assessment 1, Harrison Pickett, 4-1-19

parent 7805f22d
......@@ -7,7 +7,8 @@ public class AssessmentPartOne {
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
if (num1<num2)
if (num1>num2)
//line 10 changed < to >
{
if (num3>num1)
{
......@@ -26,11 +27,13 @@ public class AssessmentPartOne {
}
else
{
return num2
return num2;
//Line 29: added missing ; to end of line
}
}
}
public int sumNumbersBetween(int start, int end)
{
// 02 - Adding Across A Range
......@@ -44,8 +47,27 @@ public class AssessmentPartOne {
int sumOfSquares = 0;
if ((start==end) || ((start<0) || (end<0)) || (start>end) || (end-start==1))
/*
* catches all failure conditions
* start==end - if both values are equal
* start<0, end<0 - if any value is negative
* start>end - if the start is bigger than the end
* end-start==1 - ensures that there as at least 1 value between start and end
*/
{
return -1;
//returns -1 if any of these conditions are met
}
for (int index=start+1;index<end;index++)
{
//iterates through a loop from the start digit+1 so as not to include start value
sumOfSquares=sumOfSquares+index;
//running total that adds itself to the current index
}
return sumOfSquares;
//returns final result when completed
}
}
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