Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a program do that: program start by asking the user to enter the name of

ID: 3636097 • Letter: I

Question

I have a program do that:
program start by asking the user to enter the name of an input text file. Your program should then read all characters in the text file and print to the screen and to user-specified text file all letters that occurred in the input file (including space, punctuation and other symbols), with the number of times each character occurred. The program should also print to the output file all bigrams and the number of occurrence of each bigram. A bigram is defined as a set of two characters that occur after each other.

And this is the program:
package project2;
import java.util.*;
import java.io.*;

public class Project2
{
public static void main(String[] args) throws FileNotFoundException
{
PrintStream out = new PrintStream ("output.txt");
System.out.println("Enter the input text file: << 15 character please");
Scanner con = new Scanner(System.in);
String FileName = con.next();
File f = new File(FileName);
while(!f.exists())
{
System.out.println("The name for the file is wrong ,Enter the file name");
FileName = con.next();
f = new File(FileName);
}
Scanner input = new Scanner(f);
String Allword=input.next();
String word = Allword;
System.out.print(word+" ");
while(input.hasNext())
{
word = input.next();
System.out.print(word+" ");
Allword = Allword +" "+ word;
}
System.out.println();
System.out.println();
int numOfChar= Allword.length();
System.out.println("Input file contains "+numOfChar+" characters");
Set<Character> Char1 = new HashSet<Character>();
for(int i =0 ; i < Allword.length();i++)
{
char a = Allword.charAt(i);
Char1.add(a);
}
int x = Char1.size();
System.out.println("input file contains " + x + " different Characters");
Iterator <Character> itr = Char1.iterator();
Map<Character, Integer> charCount = new HashMap<Character, Integer>();
while(itr.hasNext())
{
charCount.put(itr.next(), 0);
}
for(int w = 0 ; w < Allword.length();w++)
{
if(charCount.containsKey(Allword.charAt(w)))
{
int count = charCount.get(Allword.charAt(w));
charCount.put(Allword.charAt(w), count+1);
}
}
out.println(charCount);
ArrayList <String> bigram = new ArrayList<String>();
for(int h = 0 ; h< Allword.length()-1;h++)
{
if(h==0){
bigram.add(" "+Allword.charAt(h));
bigram.add(Allword.charAt(h)+""+Allword.charAt(h+1));
}
else
bigram.add(Allword.charAt(h)+""+Allword.charAt(h+1));
}
System.out.println();
System.out.println("ther is "+ bigram.size()+" bigram");
Set<String> bigram1 = new HashSet<String>();
bigram1.addAll(bigram);
System.out.println("there is "+bigram1.size()+ " diffrenet bigram");
Iterator <String> itr2 = bigram1.iterator();
Map<String , Integer> bigramCount = new HashMap<String , Integer>();
while(itr2.hasNext())
{
bigramCount.put(itr2.next(), 0);
}
for(int y = 0; y<bigram.size();y++)
{
if(bigramCount.containsKey(bigram.get(y)));
{
int count2 = bigramCount.get(bigram.get(y)) + 1 ;
bigramCount.put(bigram.get(y), count2);
}
}
out.println();
out.println(bigramCount);
}
}


------------------- What I need ?---------------


I need to complete the program to do this :

Modify the program to calculate statistics about letters. The new program should start by asking the user to enter the name of an input text file. Your program should then read all characters in the text file and print to the screen and to a text file all letters that occurred in the input file (including space, punctuation and other symbols), with the number of times each character occurred. The name of the file for statistics about letters should be “1letters.txt”. The program should also ask the user for N, the level of N-grams that should be calculated. It should then print to separate text files all N-grams and the number of occurrence of each N-gram. The name of the file for statistics about an N-gram should start with the level of the N-Gram followed by the word “letters”. Thus for bigrams the file should be named 2letters, for trigrams the file should be named 3letters, etc… The same thing should be done for word N-Grams.

-----------------
pleas help me >>
thanks.

Explanation / Answer

Here is the required program help http://pages.cs.wisc.edu/~cs368-1/JavaTutorial/NOTES/JavaIO_Scanner.html