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
4c5c3216
Commit
4c5c3216
authored
Jan 02, 2019
by
samuelboulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished
parent
33dec52f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
AssessmentPartOne.java
src/AssessmentPartOne.java
+19
-17
No files found.
src/AssessmentPartOne.java
View file @
4c5c3216
...
@@ -3,9 +3,10 @@ public class AssessmentPartOne {
...
@@ -3,9 +3,10 @@ public class AssessmentPartOne {
public
int
biggestOfThree
(
int
num1
,
int
num2
,
int
num3
)
public
int
biggestOfThree
(
int
num1
,
int
num2
,
int
num3
)
{
{
// 01 - A Gentle Start
/* 01 - A Gentle Start
// 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
)
{
{
...
@@ -33,48 +34,49 @@ public class AssessmentPartOne {
...
@@ -33,48 +34,49 @@ public class AssessmentPartOne {
public
int
sumNumbersBetween
(
int
start
,
int
end
)
public
int
sumNumbersBetween
(
int
start
,
int
end
)
{
{
// 02 - Adding Across A Range
/* 02 - Adding Across A Range
// Complete this method so that it adds together all
Complete this method so that it adds together all
// the integers between start and end, but not including
the integers between start and end, but not including
// start or end
start or end
// This method should only deal with 0 and positive integers
This method should only deal with 0 and positive integers
// This method should return -1 if it cannot calculate the result
This method should return -1 if it cannot calculate the result
// 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
num1
=
start
;
int
num1
=
start
;
int
num2
=
end
;
int
num2
=
end
;
// First
IF
statement is to make sure the first number is equal to or more than 0
// First
if
statement is to make sure the first number is equal to or more than 0
if
(
num1
>=
0
)
if
(
num1
>=
0
)
{
{
// Second
IF
statement is to make sure that the second number is equal to or more than 0
// Second
if
statement is to make sure that the second number is equal to or more than 0
if
(
num2
>=
0
)
if
(
num2
>=
0
)
{
{
//
FOR
loop to work out the total of the numbers inside of the 2 numbers.
//
for
loop to work out the total of the numbers inside of the 2 numbers.
for
(
int
i
=
num1
+
1
;
i
<
num2
;
i
++)
for
(
int
i
=
num1
+
1
;
i
<
num2
;
i
++)
{
{
sumOfSquares
=
sumOfSquares
+
i
;
sumOfSquares
=
sumOfSquares
+
i
;
}
}
//
IF
statement to filter the answers that are less that 1
//
if
statement to filter the answers that are less that 1
if
(
sumOfSquares
<
1
)
if
(
sumOfSquares
<
1
)
{
{
// Which then returns -1 as the answer
// Which then returns -1 as the answer
return
-
1
;
return
-
1
;
}
}
//
I
f the sum is 1 or more then it returns sumOfSquares
//
i
f the sum is 1 or more then it returns sumOfSquares
else
else
{
{
return
sumOfSquares
;
return
sumOfSquares
;
}
}
}
}
//
I
f number 2 is less than 0 it returns -1
//
i
f number 2 is less than 0 it returns -1
else
else
{
{
return
-
1
;
return
-
1
;
}
}
}
}
//
I
f number 1 is less than 0 it returns -1
//
i
f number 1 is less than 0 it returns -1
else
else
{
{
return
-
1
;
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