Commit 84bd14f2 authored by Jamjars's avatar Jamjars

Final Tweaks

parent 36e972be
...@@ -42,15 +42,15 @@ public class AssessmentPartOne { ...@@ -42,15 +42,15 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does // You should comment your code explaining what each part does
int sumOfSquares = 0; int sum = 0; //int for storing the total
if (start < 0 || end < 0 || end - start < 2) { //catches invalid inputs (negative start or end values and no values in between) if (start < 0 || end < 0 || end - start < 2) { //catches invalid inputs (negative start or end values and no values in between)
return -1; return -1;
} else { } else {
for (int i = 1; i < end - start; i++) { //iterates through numbers between for (int i = 1; i < end - start; i++) { //iterates through numbers between start and end
sumOfSquares += (start + i); //adds value to the running total sum += (start + i); //adds value to the running total
} }
return sumOfSquares; return sum; //returns the final total
} }
......
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