Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AssessmentPart1
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
norbert.dajnowski
AssessmentPart1
Commits
3e74b493
Commit
3e74b493
authored
Nov 23, 2018
by
norbertdajnowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit 1
parent
7805f22d
Pipeline
#314
failed with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
8 deletions
+27
-8
AssessmentPartOne.java
src/AssessmentPartOne.java
+27
-8
No files found.
src/AssessmentPartOne.java
View file @
3e74b493
...
@@ -7,26 +7,26 @@ public class AssessmentPartOne {
...
@@ -7,26 +7,26 @@ 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
)
{
{
if
(
num3
>
num1
)
if
(
num3
>
num2
)
//num1 changed to num2 as num1 can't be the largest integer due to the last if statement
{
{
return
num3
;
return
num3
;
}
}
else
else
{
{
return
num
1
;
return
num
2
;
//num1 changed to num2 as num1 can't be the largest integer due to the if statement
}
}
}
}
else
else
{
{
if
(
num3
>
num2
)
if
(
num3
>
num1
)
//num1 to num2 as num2 has already been tested in the last if statement
{
{
return
num3
;
return
num3
;
}
}
else
else
{
{
return
num
2
return
num
1
;
//added semi-colon to avoid syntax bug and changed num2 to num1 as num2 has already been checked and is not the largest
}
}
}
}
}
}
...
@@ -42,10 +42,29 @@ public class AssessmentPartOne {
...
@@ -42,10 +42,29 @@ 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
;
//Integer to store the sum across the range
if
((
start
<
0
)
||
(
end
<
0
))
{
//-1 returned if start or end are negative values to show that they can't be calculated
return
sumOfSquares
=
-
1
;
}
while
(
start
<
end
-
1
)
{
//Creates a while loop that traverses the range from start to end
start
++;
//start incremented
sumOfSquares
=
sumOfSquares
+
start
;
//start added onto sumOfSquares
}
if
(
sumOfSquares
==
0
){
//if the program is not able to calculate a range then -1 is returned
sumOfSquares
=
-
1
;
}
return
sumOfSquares
;
//Returns the sumOfSquares if no negative values have been found
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