CMPR 120 – Introduction to Programming Homework #10 Solved

25.00 \$

Category:

Description

CMPR 120 – Introduction to Programming Homework #10 Solved
5 (100%) 1 vote[s]

Write a program that reads words from a file and writes them, grouped by length, into another file.

Your program should read each word from a file, check to see if it is already in the array and, if not, add it to the array. For this homework, “word” means what you get when you use >> to input a string.

After all words have been processed, you program should determine the length of the longest word in the array. Just loop through the array and remember the longest length seen.

Finally, your program should output (into another text file) lists of words by length. First, all words with length 1 should be outputted on one line, separated by spaces. Next, all words with length 2, then 3, up to the longest word. Loop on lengths from 1 to longest. Inside that loop (for each length), loop through the entire array, outputting words matching the desired length.

In order to determine the length of a word (string), use the string length method. For example, if we have a string named word, then it’s length can be acquired by calling the function word.length(), which returns an integer.

The executable program Gold10.exe provides demonstration of what your program should do.

Your program should be designed and implemented using top-down programming techniques: use functions for sub-tasks. The functions should be divided among three files: one for main, one for the tools, and one for the program-specific functions. You should turn in a structure chart that shows the structure of the program-specific functions in your program.

You should turn in (in a pocket folder): this assignment/grading sheet, a statement of completeness, a structure chart, and printouts of your program-specific functions (including any tools that you create). All items should be labeled appropriately. You should also submit a “soft” (electronic) copy of all of your program source files (.cpp & .h – this includes tools) via Canvas.