Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Maths assessment.
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
daniel.parker
Maths assessment.
Commits
4b4a9ef2
Commit
4b4a9ef2
authored
Dec 13, 2018
by
daniel.parker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second
parent
60c70f61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
.DS_Store
.DS_Store
+0
-0
Program.java
src/Program.java
+27
-4
No files found.
.DS_Store
0 → 100644
View file @
4b4a9ef2
File added
src/Program.java
View file @
4b4a9ef2
...
...
@@ -69,6 +69,8 @@ public class Program {
String
[]
input
=
{
"010"
,
"110"
,
"111"
,
"1010101"
};
String
[]
input2
=
{
"50"
,
"110"
,
"FA"
,
"B0"
,
"F"
};
int
[]
set
=
{
3
,
6
,
7
,
9
,
8
,
7
,
7
,
6
,
5
,
15
};
System
.
out
.
println
(
Median
(
set
));
System
.
out
.
println
(
ConvertSingb3ToInt
(
"12"
));
System
.
out
.
println
(
ConvertSingb20ToInt
(
"50"
));
System
.
out
.
println
(
ConvertSingleHexToInt
(
"50"
));
...
...
@@ -387,16 +389,37 @@ public static int Range (int[] input) {
public
static
int
Mode
(
int
[]
input
)
{
int
output
=
0
;
int
returnValue
=
input
[
0
];
int
repeatCounter
=
0
;
int
repeater
=
0
;
return
output
;
for
(
int
i
=
0
;
i
<
input
.
length
;
i
++)
{
for
(
int
compare
=
i
;
compare
<
input
.
length
;
compare
++)
{
if
(
i
!=
compare
&&
input
[
i
]==
input
[
compare
])
{
repeatCounter
++;
if
(
repeatCounter
>=
repeater
)
{
returnValue
=
input
[
i
];
}
repeater
=
repeatCounter
;
}
repeatCounter
=
0
;
}
}
return
returnValue
;
}
public
static
double
Median
(
int
[]
input
)
{
Arrays
.
sort
(
input
);
int
output
=
0
;
double
output
=
0
;
if
(
input
.
length
%
2
==
0
)
{
int
lowerMiddle
=
input
[(
int
)
input
.
length
/
2
-
1
];
int
higherMiddle
=
input
[(
int
)
input
.
length
/
2
];
output
=
lowerMiddle
+
higherMiddle
;
output
=
output
/
2
;
}
else
{
output
=
input
[
input
.
length
/
2
];}
return
output
;
}
...
...
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