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

Hello , I am having trouble computing the frequencies of characters in a given i

ID: 3742343 • Letter: H

Question

Hello , I am having trouble computing the frequencies of characters in a given input file.(Ignoring all tabs, spaces and line returns)

I have to :   

Input: a txt file (use argv[])

Output: a txt file (use argv[]) with the following format:

Char 1 # count (and so on for every other char)

This is on Huffman Coding if that helps.

Thankyou for any of your help in advance.

Explanation / Answer

import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class CharacterFrequencies { public static void main(String[] args) { if(args.length > 1) { String inputFilename = args[0]; String outputFilename = args[1]; try { Scanner fin = new Scanner(new File(inputFilename)); Map map = new HashMap(); String line; while (fin.hasNextLine()) { line = fin.nextLine(); for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote