-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort2DArray
188 lines (100 loc) · 3.22 KB
/
sort2DArray
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// CALL INGESTDATA CLASS
ingestData.main();
}
}
class ingestData {
public static void main() {
File f = new File("FBLA.txt");
try {
//Scanner to read file
Scanner sc = new Scanner(f);
//Determine the length of FBLA.txt
BufferedReader reader = new BufferedReader(new FileReader("FBLA.txt"));
int lines = 0;
while (reader.readLine() != null) lines++;
reader.close();
//Create 2-D Array
String[][] arrayOfArrays = new String[lines][3];
while(sc.hasNextLine()) {
//Declare
String lineParse = sc.nextLine();
int s = 0;
//Split the values
String [] parts = lineParse.split("\t");
String conName = (parts[0]), gender = (parts[1]), grade = (parts[2]), answer = (parts[3]);
String genGrade = gender + grade;
String [] ConString = {conName, genGrade, answer};
//Put ConString into its respective files
arrayOfArrays[s][0] = ConString[0];
arrayOfArrays[s][1] = ConString[1];
arrayOfArrays[s][2] = ConString[2];
//Print Test
System.out.print("Name: ");
System.out.println(arrayOfArrays[s][0]);
System.out.print("Grade/Gender: ");
System.out.println(arrayOfArrays[s][1]);
System.out.print("Student Answer Code: ");
System.out.println(arrayOfArrays[s][2]);
System.out.println("");
s = s + 1;
}
//The Original While Loop (Contents; TO BE USED LATER)
/*
while(sc.hasNextLine()) {
//Declare
String lineP = sc.nextLine();
//Split the values
String [] parts = lineP.split("\t");
String name = (parts[0]), gender = (parts[1]), grade = (parts[2]), answer = (parts[3]);
String genGrade = gender + grade;
String s = "";
String [] contents = {name, genGrade, s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s};
//Split the Answer
for(int a = 0; a < 30; a++) {
String aPlus = (answer.substring(a, a + 1));
contents [a + 2] = aPlus;
} //End of the "a" {_for_} loop
} //End of the {_while_} loop
*/
} //End of the {_try_}
//Catch {_file_f_}
catch(Exception e) { System.out.println(" :( "); }
//Fill Boxes
int percentMatch = 0;
int pArray = 0;
int box1 = 0; int box2 = 0; int box3 = 0; int box4 = 0; int box5 = 0; int box6 = 0;
if(percentMatch > box1) {
box1 = pArray;
box2 = box1; box3 = box2;box4 = box3;box5 = box4;box6 = box5;
} else if (percentMatch > box2) {
box2 = pArray;
box3 = box2;box4 = box3;box5 = box4;box6 = box5;
} else if (percentMatch > box3) {
box3 = pArray;
box4 = box3;box5 = box4;box6 = box5;
} else if (percentMatch > box4) {
box4 = pArray;
box5 = box4;box6 = box5;
} else if (percentMatch > box5) {
box5 = pArray;
box6 = box5;
} else if (percentMatch > box6) {
box6 = pArray;
}
try {
Scanner sc = new Scanner(f);
}
catch(Exception e) {
System.out.println(" :( ");
}
}
}