-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
57 lines (51 loc) · 1.54 KB
/
Main.java
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
import java.io.IOException;
import java.io.File;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
// read data from text file & put in an array
File fileName = new File("valid-bank.csv");
Scanner inFile = new Scanner(fileName);
int numValues = 0;
int[][] dist = new int[5][26];
int[] LetterList = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int index = 0;
// calcualtes the length of the file
while (inFile.hasNextLine()) {
inFile.nextLine();
numValues++;
}
inFile.close();
// System.out.println(numValues);
//copies the values in the file to an array
String[] words = new String[numValues];
inFile = new Scanner(fileName);
while (inFile.hasNext()) {
words[index] = inFile.next();
index++;
}
inFile.close();
//System.out.println(words[23]);
index = 0;
while (index < numValues){
//System.out.println(words[index]);
for (int i = 0; i < words[index].length(); i++){
//System.out.println(words[index].charAt(i));
for (int j = 0; j < 26; j++){
if (LetterList[j] == words[index].charAt(i)){
dist[i][j]++;
//words[index].charAt(i)
}
}
}
index++;
}
for(int i = 0; i < 5; i++){
for(int j = 0; j < 26; j++){
System.out.print(dist[i][j] + ", ");
}
System.out.println("");
}
//System.out.println(index);
}
}