In my long-time efforts I finally finished the simple task, I tried several methods, finally succeeded, but also drunk.
In order to be able to display the most occurrences of the letter and the number of times, I have a mistake after the use of a similar two-paragraph program, I succeeded.
Import Java.io.BufferedReader;
Import Java.io.File;
Import java.io.FileNotFoundException;
Import Java.io.FileReader;
Import java.io.IOException;
public class Count {
public static void Main (string[] args) {
String Path = "C:/users/86173/desktop/englishartical.txt";
File File = new file (path);
Int[] Count=new int[26];
Int[] Count2=new int[26];
for (int i=0;i<26;i++)
{
Char a= ' a ';
int n= ((int) a+i);
Char des = (char) n;
int count1 = Process (file, DES);
Count[i]=count1;
System.out.println ("character" + des + "in the presence of" + count[i]+ "Times");
}
for (int i=0;i<26;i++)
{
Char a= ' a ';
int n= ((int) a+i);
Char des = (char) n;
int count1 = Process (file, DES);
Count2[i]=count1;
System.out.println ("character" + des + "appears" + count2[i]+ "Times");
}
int j=0,k=0;
int maxIndex1 = count[0];
int minIndex1 = count[0];
for (int i = 0; i < count.length; i++) {
if (MaxIndex1 < count[i]) {
MaxIndex1 = Count[i];
J=i;
}
if (MinIndex1 > Count[i]) {
MinIndex1 = Count[i];
}
}
int maxIndex2 = count2[0];
int minIndex2 = count2[0];
for (int i = 0; i < count2.length; i++) {
if (MaxIndex2 < count2[i]) {
MaxIndex2 = Count2[i];
K=i;
}
if (MinIndex2 > Count2[i]) {
MinIndex2 = Count2[i];
}
}
if (MAXINDEX1>MAXINDEX2)
{char a= ' a ';
int n= ((int) a+j);
Char des = (char) n;
System.out.println ("character" + des + "occurs at most times:" +maxindex1);
}
else if (MAXINDEX1<MAXINDEX2)
{char a= ' a ';
int n= ((int) a+k);
Char des = (char) n;
System.out.println ("character" + des + "occurs at most times:" +maxindex2);
}
}
public static int process (file file, char c) {
int count = 0;
BufferedReader br = null;
try {
br = new BufferedReader (new FileReader (file));
String temp = "";
while (temp = br.readline ()) = null) {
char[] des = Temp.trim (). ToCharArray ();
for (int i = 0; i < des.length; i++) {
if (des[i] = = c) {
count++;
}
}
}
} catch (FileNotFoundException e) {
E.printstacktrace ();
} catch (IOException e) {
E.printstacktrace ();
} finally {
try {
Br.close ();
} catch (IOException e) {
E.printstacktrace ();
}
}
return count;
}
}
Hamlet feedback a bitter tear