-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmidterm.java
More file actions
111 lines (82 loc) · 1.83 KB
/
Copy pathmidterm.java
File metadata and controls
111 lines (82 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package classExamples;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.HashSet;
import java.util.Set;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Collections;
import java.util.TreeMap;
import java.util.Map;
public class midterm
{
public static int numGCs(String parameter)
{
int counter = 0;
for (int i = 0; i < parameter.length(); i++)
{
if ((parameter.charAt(i) == 'G') || (parameter.charAt(i) == 'C'))
{
counter++;
}
}
return(counter);
}
public static int bothPositive(int a, int b)
{
if ((a > 0) && (b > 0))
{
return(1);
}
return(0);
}
public static void skipEveryOther(String s)
{
for (int i = 0; i < s.length(); i = i + 2)
{
System.out.println(s.charAt(i));
}
}
public static void reverseArray(float[] a)
{
float b[] = new float[a.length];
int countUp = 0;
for (int i = a.length -1; i >= 0; i--)
{
b[countUp] = a[i];
countUp++;
}
//for (int i = 0; i < b.length; i++)
//{
// System.out.println(b[i]);
//}
a = b;
}
/*Returns a List containing all the Integers in inList that are even. The order of Integers in the return List is the same as in inList*/
public static List<Integer> getEvenNumbers( List<Integer> inList )
{
List<Integer> evenNumbers = new ArrayList<Integer>();
for (int i = 0; i < inList.size(); i++)
{
if (inList.get(i) % 2 == 0)
{
evenNumbers.add(inList.get(i));
}
}
return(evenNumbers);
}
public int aMethod(int anInt)
{
return anInt;
}
public static void main(String[] args) throws Exception
{
float[] array = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f ,7.0f, 8.0f};
reverseArray(array);
for (float c : array)
{
System.out.println(c);
}
}
}