Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Programming-01-Assesment-01
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
ben.coxford
Programming-01-Assesment-01
Commits
930b5890
Commit
930b5890
authored
Dec 06, 2018
by
Benco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Task1 Complete.
parent
2fe07381
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
AssessmentPartOne.java
src/AssessmentPartOne.java
+19
-2
No files found.
src/AssessmentPartOne.java
View file @
930b5890
...
@@ -42,10 +42,27 @@ public class AssessmentPartOne {
...
@@ -42,10 +42,27 @@ 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
;
//Defines and initialises the total value.
if
(
start
<
end
-
1
)
{
//Validates whether there are any numbers between the start and end and whether the start value is less than the end value.
if
(!(
start
<
0
)
||
(
end
<
0
))
{
//Validates that both the start and end values are not negative numbers.
return
sumOfSquares
;
//Adds up all values from the start to the end exclusive of themselves.
for
(
int
i
=
start
+
1
;
i
<
end
;
i
++)
{
sumOfSquares
=
sumOfSquares
+
i
;
}
}
else
{
//If the start and end value is a negative number.
sumOfSquares
=
-
1
;
//Sets the sumOfSquares to -1; indicating that the calculation cannot be carried out.
}
}
else
{
//If there are no values between the start and end or if the start value is less than the end value.
sumOfSquares
=
-
1
;
//Sets the sumOfSquares to -1; indicating that the calculation cannot be carried out.
}
return
sumOfSquares
;
//Returns the value.
}
}
}
}
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