mardi 21 juin 2016

Need helf wit this C++ assignment [on hold]

Write a C++ program to compute basic statistics of the words in text file words.txt – the input file. Each line in the input file contains exactly one word. The words in the input file are sorted lexicographically in dictionary style.

The program will write its output into another text file words_statistics.txt – the output file. The output file will contain a line (or lines) at the beginning of the file explaining the output. This is followed by the following lines and corresponding computed values:

Number of words: value Average length of words: value Number of 1-letter words: value Number of 2-letter words: value Number of 3-letter words: value Number of 4-letter words: value Number of 5-letter words: value Number of 6-letter words: value Number of 7-letter words: value Number of 8-letter words: value Number of 9-letter words: value Number of 10-letter words: value Number of 11-letter words: value Number of 12-letter words: value Number of 13-letter words: value Number of words of any other number of letters: value

The C++ program will be comprised of a main function and a words_statistics function that computes and outputs the word statistics. The program will include all necessary checks and assertions.

Submit a printed report including the full, complete, and documented C++ program and a print-out of the output file. Use formatting instructions to make the layout neat and easy to read.

This is what i have so far: #include

    #include <string>

    #include <fstream>

    using namespace std;

    void word_statistics(string file_name){

    string line;

txt file word list: aa aah aahed aahing aahs aal aalii aaliis aals aardvark aardvarks aardwolf aardwolves aas aasvogel aasvogels aba abaca abacas abaci aback abacus abacuses abaft abaka abakas abalone abalones abamp abampere abamperes abamps abandon abandoned abandoning abandonment abandonments abandons abas abase abased abasedly abasement abasements abaser abasers abases abash abashed abashes abashing abasing

Aucun commentaire:

Enregistrer un commentaire