Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment01-18
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
harrison.pickett
Assessment01-18
Commits
a22e0791
Commit
a22e0791
authored
Jan 04, 2019
by
Thundy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed Programming 01 assessment 1, Harrison Pickett, 4-1-19
parent
7805f22d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
AssessmentPartOne.java
src/AssessmentPartOne.java
+25
-3
No files found.
src/AssessmentPartOne.java
View file @
a22e0791
...
...
@@ -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
}
}
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