Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AssessmentP1
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
samuel.boulton
AssessmentP1
Commits
e399b3d7
Commit
e399b3d7
authored
Dec 03, 2018
by
samuelboulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments changed
parent
7805f22d
Pipeline
#372
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
7 deletions
+41
-7
AssessmentPartOne.java
src/AssessmentPartOne.java
+41
-7
No files found.
src/AssessmentPartOne.java
View file @
e399b3d7
...
...
@@ -9,24 +9,24 @@ public class AssessmentPartOne {
if
(
num1
<
num2
)
{
if
(
num3
>
num
1
)
if
(
num3
>
num
2
)
// changed num1 to num2
{
return
num3
;
}
else
{
return
num
1
;
return
num
2
;
// changed num1 to num2
}
}
else
{
if
(
num3
>
num
2
)
if
(
num3
>
num
1
)
// changed num2 to num1
{
return
num3
;
}
else
{
return
num
2
return
num
1
;
//added ';' // changed num2 to num1
}
}
}
...
...
@@ -43,9 +43,43 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
int
sumOfSquares
=
0
;
int
num1
=
start
;
int
num2
=
end
;
// First IF statement is to make sure the first number is equal to or more than 0
if
(
num1
>=
0
)
{
// Second IF statement is to make sure that the second number is equal to or more than 0
if
(
num2
>=
0
)
{
// FOR loop to work out the total of the numbers inside of the 2 numbers.
for
(
int
i
=
num1
+
1
;
i
<
num2
;
i
++)
{
sumOfSquares
=
sumOfSquares
+
i
;
}
// IF statement to filter the answers that are less that 1
if
(
sumOfSquares
<
1
)
{
// Which then returns -1 as the answer
return
-
1
;
}
// If the sum is 1 or more then it returns sumOfSquares
else
{
return
sumOfSquares
;
}
}
// If number 2 is less than 0 it returns -1
else
{
return
-
1
;
}
}
// If number 1 is less than 0 it returns -1
else
{
return
-
1
;
}
}
}
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