Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AssessmentPart1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nathan.joynes
AssessmentPart1
Commits
d72bfe36
Commit
d72bfe36
authored
Nov 05, 2018
by
nathan.joynes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parent
7805f22d
Pipeline
#222
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
AssessmentPartOne.java
src/AssessmentPartOne.java
+23
-3
No files found.
src/AssessmentPartOne.java
View file @
d72bfe36
...
...
@@ -7,7 +7,10 @@ public class AssessmentPartOne {
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
if
(
num1
<
num2
)
// I have changed the logical error in the first line to correct the initial error and make the code run correctly.
// In this case the sign was the opposite way round.
if
(
num1
>
num2
)
{
if
(
num3
>
num1
)
{
...
...
@@ -25,8 +28,9 @@ public class AssessmentPartOne {
return
num3
;
}
else
// Syntax error: I have added in the missing ; to the following line.
{
return
num2
return
num2
;
}
}
}
...
...
@@ -42,9 +46,25 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
int
sumOfSquares
=
0
;
// Here I am declaring the variable of int sumOfSquares at the beginning of my method.
int
sumOfSquares
=
0
;
// I have validated my start variable to ensure that it starts at 0 or above.
if
(
start
<=
-
1
)
return
-
1
;
// I have also done the same here with the 'end' variable to ensure that this is also greater than or equal to 0.
if
(
end
<=
-
1
)
return
-
1
;
// Here I am checking that the start variable is bigger than the end variable. This throws -1 of the start is greater than end.
if
(
end
-
1
<=
start
+
1
)
return
-
1
;
// This for loop allows me to grab the range between the start end variables excluding both the start and end value.
for
(
int
i
=
start
+
1
;
i
<=
end
-
1
;
i
++)
//This adds the ith value to the running total.
sumOfSquares
=
sumOfSquares
+
i
;
// Method end.
return
sumOfSquares
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment