Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Maths1
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
Maths1
Commits
76667ddc
Commit
76667ddc
authored
Dec 04, 2018
by
samuel.boulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated
parent
3311bd17
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
36 deletions
+101
-36
.classpath
.classpath
+1
-1
org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+3
-3
Program.java
src/Program.java
+95
-30
ProgramTest.java
src/ProgramTest.java
+2
-2
No files found.
.classpath
View file @
76667ddc
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1
0
"
>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1
.8
"
>
<attributes>
<attributes>
<attribute
name=
"module"
value=
"true"
/>
<attribute
name=
"module"
value=
"true"
/>
</attributes>
</attributes>
...
...
.settings/org.eclipse.jdt.core.prefs
View file @
76667ddc
eclipse.preferences.version=1
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1
0
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1
.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1
0
org.eclipse.jdt.core.compiler.compliance=1
.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=1
0
org.eclipse.jdt.core.compiler.source=1
.8
src/Program.java
View file @
76667ddc
...
@@ -72,7 +72,7 @@ public class Program {
...
@@ -72,7 +72,7 @@ public class Program {
int
[]
resultsArray
=
new
int
[
binaryArray
.
length
];
int
[]
resultsArray
=
new
int
[
binaryArray
.
length
];
/*Needs a lot of work.
char
[]
binCA
=
binaryInput
[
0
].
toCharArray
();
char
[]
binCA
=
binaryInput
[
0
].
toCharArray
();
int
binTotal
=
0
;
int
binTotal
=
0
;
int
binCM
=
0
;
int
binCM
=
0
;
...
@@ -85,12 +85,55 @@ public class Program {
...
@@ -85,12 +85,55 @@ public class Program {
}
}
System
.
out
.
println
(
binTotal
);
System
.
out
.
println
(
binTotal
);
*/
// loop to go round each string, and do something in the string to characterise it.
return
resultsArray
;
return
resultsArray
;
}
}
/*
public static int ConvertASingleBinaryToInt(String someBinary) {
int result = 0;
return result;
}
public static int[] ConvertWordsToInt(String[] wordArray) {
int[] resultsArray = new int[wordArray.length];
for(int i = 0; i<wordArray.length; i++) {
resultsArray[i] = ConvertASingleWordToInt(wordArray[i]);
}
return resultsArray;
}
public static int ConvertASingleWordToInt(String someWord) {
int result = 0;
if(someWord == "eleven") {result = 11;}
return result;
}
*/
...
@@ -116,19 +159,42 @@ public class Program {
...
@@ -116,19 +159,42 @@ public class Program {
ArrayList
<
Integer
>
unionList
=
new
ArrayList
<
Integer
>();
ArrayList
<
Integer
>
unionList
=
new
ArrayList
<
Integer
>();
/*this is the same as the intersection
for
(
int
i
=
0
;
i
<
intArrayA
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
intArrayA
.
length
;
i
++)
{
{
unionList
.
add
(
intArrayA
[
i
]);
for
(
int
k
=
0
;
k
<
intArrayB
.
length
;
k
++)
for
(
int
k
=
0
;
k
<
intArrayB
.
length
;
k
++)
{
{
if(intArrayA[i] == intArrayB[i])
unionList
.
add
(
intArrayB
[
k
]);
if
(
intArrayA
[
i
]
!=
intArrayB
[
k
])
{
{
unionList
.
add
(
intArrayB
[
k
]);
unionList
.
add
(
intArrayA
[
i
]);
}
}
}
}
}
}
*/
/*
for (int j = 0; j < unionList.size(); j++)
{
if(unionList.get(j) == intArrayA[i])
{
unionList.remove(j);
}
}
for(int k = 0; k < intArrayB.length; k++)
{
unionList.add(intArrayB[k]);
for(int l = 0; l < unionList.size(); l++)
{
if(unionList.get(l) == intArrayB[k])
{
unionList.remove(l);
}
}
}
*/
int
[]
resultsArray
=
new
int
[
unionList
.
size
()];
int
[]
resultsArray
=
new
int
[
unionList
.
size
()];
for
(
int
i
=
0
;
i
<
unionList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
unionList
.
size
();
i
++)
{
resultsArray
[
i
]
=
unionList
.
get
(
i
);
resultsArray
[
i
]
=
unionList
.
get
(
i
);
...
@@ -143,26 +209,24 @@ public class Program {
...
@@ -143,26 +209,24 @@ public class Program {
public
static
int
[]
Intersection
(
int
[]
intArrayA
,
int
[]
intArrayB
)
{
public
static
int
[]
Intersection
(
int
[]
intArrayA
,
int
[]
intArrayB
)
{
// DONE AND PASSED TEST
ArrayList
<
Integer
>
intersectList
=
new
ArrayList
<
Integer
>();
ArrayList
<
Integer
>
intersectList
=
new
ArrayList
<
Integer
>();
int
results
=
0
;
// **************** Ask how do i return it and where does the output go???*****************
/*
//looking through intArrayA
for
(
int
j
=
0
;
j
<
intArrayA
.
length
;
j
++)
for
(
int
j
=
0
;
j
<
intArrayA
.
length
;
j
++)
{
{
// looking through intArrayB
for
(
int
k
=
0
;
k
<
intArrayB
.
length
;
k
++)
for
(
int
k
=
0
;
k
<
intArrayB
.
length
;
k
++)
{
{
// Working out what is used in both arrays
if
(
intArrayA
[
j
]
==
intArrayB
[
k
])
if
(
intArrayA
[
j
]
==
intArrayB
[
k
])
{
{
intersectList
.
add
(
intArrayA
[
j
]);
}
}
}
}
}
}*/
//This was here
int
[]
resultsArray
=
new
int
[
intersectList
.
size
()];
int
[]
resultsArray
=
new
int
[
intersectList
.
size
()];
for
(
int
i
=
0
;
i
<
intersectList
.
size
();
i
++)
for
(
int
i
=
0
;
i
<
intersectList
.
size
();
i
++)
{
{
...
@@ -352,18 +416,19 @@ public static int Range (int[] input) {
...
@@ -352,18 +416,19 @@ public static int Range (int[] input) {
public
static
double
StandardDeviation
(
int
[]
input
)
{
public
static
double
StandardDeviation
(
int
[]
input
)
{
double
output
=
0
;
// ask about calcualtions
// should be working!
// the mean works
float
mean
=
0
;
float
totalMean
=
0
;
for
(
int
i
=
0
;
i
<
input
.
length
;
i
++)
{
mean
=
mean
+
i
;
}
double
output
=
0
;
double
mean
=
0
;
double
totalMean
=
0
;
// calculate mean
for
(
int
i
=
0
;
i
<
input
.
length
;
i
++)
{
mean
+=
input
[
i
];
}
totalMean
=
mean
/
input
.
length
;
totalMean
=
mean
/
input
.
length
;
// calculate standard dev
for
(
int
j
=
0
;
j
<
input
.
length
;
j
++)
for
(
int
j
=
0
;
j
<
input
.
length
;
j
++)
{
{
output
=
output
+
j
+
(
j
-
totalMean
)*(
j
-
totalMean
);
output
=
output
+
j
+
(
j
-
totalMean
)*(
j
-
totalMean
);
...
@@ -385,7 +450,7 @@ public static int Range (int[] input) {
...
@@ -385,7 +450,7 @@ public static int Range (int[] input) {
for
(
int
i
=
0
;
i
<
input
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
input
.
length
;
i
++)
{
{
sum
=
sum
+
1
/
input
[
i
];
sum
=
(
sum
+
1
)
/
input
[
i
];
}
}
output
=
input
.
length
/
sum
;
output
=
input
.
length
/
sum
;
...
...
src/ProgramTest.java
View file @
76667ddc
...
@@ -109,7 +109,7 @@ class ProgramTest {
...
@@ -109,7 +109,7 @@ class ProgramTest {
void
testIntersection
()
{
void
testIntersection
()
{
int
[]
setA
=
{
3
,
6
,
8
,
4
,
2
,
1
};
int
[]
setA
=
{
3
,
6
,
8
,
4
,
2
,
1
};
int
[]
setB
=
{
3
,
6
,
7
,
9
,
8
,
7
,
6
,
5
,
15
};
int
[]
setB
=
{
3
,
6
,
7
,
9
,
8
,
5
,
15
};
int
[]
setC
=
{
3
,
6
,
8
};
int
[]
setC
=
{
3
,
6
,
8
};
...
@@ -138,7 +138,7 @@ class ProgramTest {
...
@@ -138,7 +138,7 @@ class ProgramTest {
void
testDifference
()
{
void
testDifference
()
{
int
[]
setA
=
{
3
,
6
,
8
,
4
,
2
,
1
};
int
[]
setA
=
{
3
,
6
,
8
,
4
,
2
,
1
};
int
[]
setB
=
{
3
,
6
,
7
,
9
,
8
,
7
,
6
,
5
,
15
};
int
[]
setB
=
{
3
,
6
,
9
,
8
,
7
,
5
,
15
};
int
[]
setC
=
{
4
,
2
,
1
};
int
[]
setC
=
{
4
,
2
,
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