Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment Part 1
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
jack.templeman
Assessment Part 1
Commits
fe1e03c5
Commit
fe1e03c5
authored
Nov 05, 2018
by
jack.templeman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parent
7805f22d
Pipeline
#227
failed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
AssessmentPartOne.java
src/AssessmentPartOne.java
+31
-2
AssessmentPartOneTest.java
src/AssessmentPartOneTest.java
+2
-0
No files found.
src/AssessmentPartOne.java
View file @
fe1e03c5
...
...
@@ -7,7 +7,7 @@ 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
)
//switched < to >
{
if
(
num3
>
num1
)
{
...
...
@@ -26,7 +26,7 @@ public class AssessmentPartOne {
}
else
{
return
num2
return
num2
;
//added semicolon
}
}
}
...
...
@@ -43,9 +43,38 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
int
sumOfSquares
=
0
;
int
negativeAnswer
=
-
1
;
//This will be returned if the range starts as a negative
if
(
start
<
0
)
{
return
negativeAnswer
;
//This returns "-1" if the range starts as a negative
}
if
(
end
-
start
==
1
)
{
return
negativeAnswer
;
//This returns "-1" if there are no values between start and end
}
if
(
start
>
end
)
{
return
negativeAnswer
;
//This returns "-1" if the end value is larger than the start
}
else
{
for
(
int
a
=
start
+
1
;
a
<
end
;
a
++)
// For loop will add all terms between start and end int
{
sumOfSquares
+=
a
;
// Adds each term to the sum value
}
}
return
sumOfSquares
;
}
}
src/AssessmentPartOneTest.java
View file @
fe1e03c5
...
...
@@ -40,5 +40,7 @@ class AssessmentPartOneTest {
})
void
testSumNumbersBetween
(
int
num1
,
int
num2
,
int
sum
)
{
assertEquals
(
sum
,
test
.
sumNumbersBetween
(
num1
,
num2
));
}
}
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