Write a program that reads in a text file and then computes

Assignment Help JAVA Programming
Reference no: EM13168068

Write a program that reads in a text file and then computes and prints a table of letter frequencies. For example, if the file is the text of "A Tale of Two Cities", found in the file atdata/tales.txt, the program will print:

 

Please enter the pathname or URL of the book file: data/tales.txt
Letter frequencies in data/tales.txt
a        47,065
b         8,142
c        13,223
d        27,484
e        72,878
f        13,152
g        12,121
h        38,355
i        39,779
j           622
k         4,633
l        21,516
m        14,924
n        41,308
o        45,115
p         9,452
q           655
r        35,950
s        36,771
t        52,393
u        16,217
v         5,065
w        13,835
x           666
y        11,849
z           213


I am confused as to how to represent my code in this nice table above.  Any hints? Here is my code so for:
package assignment3solutions;

import java.util.ArrayList;

import stdlib.In;
import stdlib.StdIn;
import stdlib.StdOut;

public class LetterFrequencies {
        
        public static void main(String[] args){
                
                StdOut.println("Please enter the pathname or URL of the book file: ");
                String textSource = StdIn.readLine();
                
                final In in = new In(textSource);
                if(!in.exists()){
                        StdOut.print("Unable to open file " + textSource);
                System.exit(1);
                }
                
                String[] bookOfWords = bookFile.split("\\s+");
                
                ArrayList<Integer>wordFrequencies = new ArrayList<Integer>();
                
                for(String word: bookOfWords){
                        wordFrequencies.add()

 

 

Reference no: EM13168068

Questions Cloud

State bromine can form compounds or ions with any number : Bromine can form compounds or ions with any number of fluorine atoms from one to five. Write the formulas of all five of these species
State what is the equilibrium constant for the reaction : What is the equilibrium constant for the reaction N2(g) + 3 H2(g) ?? 2 NH3(g) at this temperature?
A and b, both of which perform the same function : Assume you have two algorithms, A and B, both of which perform the same function,
Compute the amount of heat energy required to convert : Calculate the amount of heat energy required to convert 55.0 g of water at 62.5 degrees Celsius to steam at 124.0 degrees Celsius
Write a program that reads in a text file and then computes : Write a program that reads in a text file and then computes and prints a table of letter frequencies. For example, if the file is the text of "A Tale of Two Cities", found in the file at data/tales.txt , the program will print
Initialized the array of words by an assignment statement. : modify the following program . The program from Lab 4 initialized the array of words by an assignment statement.
There are four conditions that are necessary : There are four conditions that are necessary for a deadlock to occur. Give an example to show that these conditions are not sufficient for a resource deadlock to occur. When are these conditions sufficient for a resource deadlock to occur? Explain..
Explain the net chemical equation : When a strong base is added to a solution of CuSO4, which is pale blue, a precipitate forms and the solution above the precipitate is colorless. The net chemical equation is Cu(2+)(aq) + 2OH(-)(aq) --> Cu(OH)2(s)
A game of tic-tac-toe : A game of tic-tac-toe, two players (one the computer) take turns marking an available cell in a 3 X 3 grid (a two dimensional array) with their respective tokens (either and X or an O). When one player has placed three tokens in a horizontal

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Write program using a switch statement that display polygon

Write a program using a switch statement that displays the name of a polygon with sides between 3 and 12 depending on the number entered by the user

  Compilation and Execution - JAVA problem

Style marks are based on how your submitted code looks. Remember that good code is easily readable (and understandable) by someone who did not write it. For assignments, you should also include your name, student number, what course this is, what ass..

  Create the working applet to compute tax

Write down a java applet. Your applet assits to find out how much federal tax we require to pay suppose the tax rate is 12%. Create and implement the working applet to compute tax.

  Java script program for song

Construct a JavaScript program that declares and prints an array that includes at least twenty of your favorite songs.

  Simulate a simple multiuser computer system

Prepare a java program to simulate a simple multiuser computer system

  Design a java program that simulates a slot machine

Design a java program that simulates a slot machine. When the program runs, it should do the following: Ask the user to enter the amount of money he or she wants to insert into the slot machine. ? Instead of displaying images, the program will random..

  Hasanodddigit that returns whether any digit

d named hasAnOddDigit that returns whether any digit of a positive integer is odd. Your method should return true if the number has at least one odd digit and false if none of its digits are odd. 0, 2, 4, 6, and 8 are even digits, and 1, 3, 5, 7, 9 a..

  Write a java program that uses a search tree of strings

Write a Java program that uses a search tree of strings to sort text lines in alphabetic order. You may choose how you de?ne alphabetic order as long as there is some sense in the de?nition. You may also choose what kind of tree you use.

  Write a class called rationalnumber

Write a class called RationalNumber that represents a fraction with an integer numerator and denominator.

  Generates n random numbers

Create a VI that generates n random numbers, where n is a user input. Display the n random numbers in an array, and in a second array display the same random umbers in ascending order.

  Java program to read line of text which ends with period

Write down the java program which will read the line of text which ends with the period, which serves as sentinel value. Show all the letters which occur in the text.

  The data file being used contains records

The data file being used contains records with an employee's name, the number of hours they worked, and their hourly pay rate. Write a program to read the records of information and output (to the Output window or a dialog box) the employee's name..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd