I am trying to get the program to print how many of each letter of the alphabet is in the bible but it is throwing and error. I am just using a small part of the bible until I get it to run properly. Please help.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Arrays;
public class Bible3
{
public static void main ( String [] args )throws FileNotFoundException
{
Scanner dataFile=new Scanner(new File("bible2.txt"));
int [] countArray = new int[26];
int alpha = 64;
while(dataFile.hasNextLine())
{
String verse = dataFile.nextLine();
verse = verse.toLowerCase();
int colonPosition = verse.indexOf(':');
int verseLength = verse.length ();
for (int current = (colonPosition + 1);(current <= (verseLength - 1)); ++ current)
{
if( ((int) verse.charAt(current) >= 97) && ((int)verse.charAt(current) <= 122))
{
++ countArray[((int) verse.charAt(current))-97];
}
System.out.println( char(++ alpha) + " " + countArray[current]);
}
}
}
Here is the text file Bible2
Genesis|1:1 In the beginning God created the heaven and the earth.
Genesis|1:2 And the earth was without form, and void; and darkness [was]
upon the face of the deep. And the Spirit of God moved upon the face of the
waters.
Genesis|1:3 And God said, Let there be light: and there was light.
Genesis|1:4 And God saw the light, that [it was] good: and God divided
the light from the darkness.
Genesis|1:5 And God called the light Day, and the darkness he called
Night. And the evening and the morning were the first day.
Genesis|1:6 And God said, Let there be a firmament in the midst of the
waters, and let it divide the waters from the waters.
Here are the errors it is showing
Bible3.java:27: '.class' expected
System.out.println( char(++ alpha) + " " + countArray[current]);
^
Bible3.java:27: ';' expected
System.out.println( char(++ alpha) + " " + countArray[current]);
^
Bible3.java:27: not a statement
System.out.println( char(++ alpha) + " " + countArray[current]);
^
Bible3.java:27: ';' expected
System.out.println( char(++ alpha) + " " + countArray[current]);
^
Bible3.java:27: not a statement
System.out.println( char(++ alpha) + " " + countArray[current]);
^
Bible3.java:27: ';' expected
System.out.println( char(++ alpha) + " " + countArray[current]);
^
6 errors