Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment 1 Part 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
liam.wadsworth
Assessment 1 Part 1
Commits
adf8d516
Commit
adf8d516
authored
Nov 05, 2018
by
liam.wadsworth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
7805f22d
Pipeline
#232
failed with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
AssessmentPartOne.java
src/AssessmentPartOne.java
+23
-6
No files found.
src/AssessmentPartOne.java
View file @
adf8d516
public
class
AssessmentPartOne
{
public
int
biggestOfThree
(
int
num1
,
int
num2
,
int
num3
)
...
...
@@ -7,7 +6,9 @@ public class AssessmentPartOne {
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
if
(
num1
<
num2
)
if
(
num1
>
num2
)
//changed the < to > as the test was only True when the 3rd number was the largest
//this happens because num1 can't be identified as the largest number as it is never checked
{
if
(
num3
>
num1
)
{
...
...
@@ -18,6 +19,7 @@ public class AssessmentPartOne {
return
num1
;
}
}
else
{
if
(
num3
>
num2
)
...
...
@@ -26,7 +28,7 @@ public class AssessmentPartOne {
}
else
{
return
num2
return
num2
;
//added semicolon after num2
}
}
}
...
...
@@ -43,8 +45,23 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does
int
sumOfSquares
=
0
;
int
sumNum
=
0
;
//This number will represent an individual number that is between the start and end
if
((
end
<
start
)||(
end
==
start
-
1
)||(
start
<
0
)||(
end
<
0
)||(
end
==
start
+
1
))
//Checks if any of the numbers are negatives or if the start number is smaller than the end number
{
sumOfSquares
=
-
1
;
//Sets sumOfSquares to -1 if any of these issues are found
return
sumOfSquares
;
}
for
(
int
i
=
1
;
i
<
(
end
-
start
);
i
++)
//Sets i to 1 and loops for the amount of numbers that are between the start and end numbers
{
sumNum
=
start
+
i
;
//Adds i to the starting number which allows the loop to get each number that is between start and end
sumOfSquares
=
sumNum
+
sumOfSquares
;
//Adds this number to the total
}
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