Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment - 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
mykel.macdonald
Assessment - 1
Commits
ab9a4627
Commit
ab9a4627
authored
Nov 05, 2018
by
mykel.macdonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inital commit
parent
7805f22d
Pipeline
#231
failed with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
AssessmentPartOne.java
src/AssessmentPartOne.java
+18
-2
No files found.
src/AssessmentPartOne.java
View file @
ab9a4627
...
@@ -7,7 +7,7 @@ public class AssessmentPartOne {
...
@@ -7,7 +7,7 @@ public class AssessmentPartOne {
// Debug this method so it passes the unit test.
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
// Add comments beside any changes you make
if
(
num1
<
num2
)
if
(
num1
>
num2
)
// I changed the < in between the "num1" and "num2" variables to >
{
{
if
(
num3
>
num1
)
if
(
num3
>
num1
)
{
{
...
@@ -26,7 +26,7 @@ public class AssessmentPartOne {
...
@@ -26,7 +26,7 @@ public class AssessmentPartOne {
}
}
else
else
{
{
return
num2
return
num2
;
// I added a end line to this line
}
}
}
}
}
}
...
@@ -43,8 +43,24 @@ public class AssessmentPartOne {
...
@@ -43,8 +43,24 @@ 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
sumOfSquares
=
0
;
int
negativeInt
=
-
1
;
// This gives a return if the sum cannot be calculated
if
(
start
<
0
)
{
// This means if the first number is negative to return the value of negativeInt being -1
return
negativeInt
;
}
if
(
end
<
0
)
{
// This means if the last number is negative to return the value of negativeInt being -1
return
negativeInt
;
}
if
(
end
<
start
)
{
// This means if the last number is less that the first number then the negativeInt value will be displayed
return
negativeInt
;
}
if
(
end
==
start
+
1
)
{
// This means if there are no numbers between the first and last then the value of negativeInt is displayed
return
negativeInt
;
}
for
(
int
i
=
start
+
1
;
i
<
end
;
i
++)
{
// This means the first number will be excluded by a value of one and the numbers before the last number are only included
sumOfSquares
+=
i
;
}
return
sumOfSquares
;
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