Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment
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
daniel.parker
Assessment
Commits
a288b5ce
Commit
a288b5ce
authored
Nov 05, 2018
by
daniel.parker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parent
7805f22d
Pipeline
#226
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
AssessmentPartOne.java
src/AssessmentPartOne.java
+25
-7
No files found.
src/AssessmentPartOne.java
View file @
a288b5ce
...
...
@@ -6,8 +6,10 @@ public class AssessmentPartOne {
// 01 - A Gentle Start
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
if
(
num1
<
num2
)
if
(
num1
>
num2
)
//reversed the < to > symbol to say if num1 is larger than num2.
//this is because otherwise the test will always find num3 as the largest
//since if num2 was larger than num1, it is completely ignored in the next "if" statement
//so num3 is always returned.
{
if
(
num3
>
num1
)
{
...
...
@@ -26,7 +28,7 @@ public class AssessmentPartOne {
}
else
{
return
num2
return
num2
;
//semicolon needed
}
}
}
...
...
@@ -43,9 +45,25 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
int
sumOfSquares
=
0
;
return
sumOfSquares
;
if
((
end
<
start
)
||
(
end
==
start
-
1
)
||
(
start
<
0
)
||
(
end
<
0
)
||
(
end
==
start
+
1
))
{
// The code above is a set of conditions to test for values which are not within the set of
//parameters stated above such as values have to be positive.
sumOfSquares
=
-
1
;
//sets value of sumOfSquares to -1 which shows an error.
return
sumOfSquares
;
// returns sumOfSquares to show error so that the rest of the code is not
// run.
}
start
=
start
+
1
;
// this sets the start value for the loop as one integer larger than the set start
// value, meaning that the original start value is not included in the addition.
for
(
int
A
=
start
;
A
<
end
;
A
++)
//This loop increments by one each time from start to end, not
//including end as i haven't used a >= symbol.
{
sumOfSquares
=
sumOfSquares
+
A
;
//this adds the next number in the increment to the total
//and repeats every time the loop runs till it is completed.
}
return
sumOfSquares
;
//this returns the new total.
}
}
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