Question: Create a program that reads a text file filled with words (for example animal names) and counts the number of occurrences of its constituent tokens

Create a program that reads a text file filled with words (for example animal names) and counts the number of occurrences of its constituent tokens using parallel iterative arrays. The arrays are limited to a capacity of 10. (The first 10 unique tokens take up the array slots.)

For the testing purposes to create 2 text files. One of them filled with max 10 words (some of them can be duplicates), and the other filled with 10 unique words and multiple repetitions. I already have some code. I need help with the rest. Open to suggestions of fixing the code. #include #include #include using namespace std;

int main() { //Declaring all variables that will be used within the main function string fileName =""; //name of the input file string fileContents=""; //contents within the input file

////Start of the program cout<<"This program will count the number of words within your selected file, using the parallel iterative arrays."<

//Promting the user for the name of the file cout<<"Please enter the name of the file: "<>fileName;

//function to find the input file ifstream MyReadFile(fileName);

// Using a while loop together with the getline() function to read the file line by line, and input it into fileContents while (getline (MyReadFile, fileContents)) { //Output the text from the file - This section is to be deleted when done, just a process to make sure that the program read the contents of the file. cout << "Your files contents: "<

// Here call the seprate function (or subfunction) that will preform the operation from the given problem.

}

Name of the file: test1.txt Contents: Dog Cat Cow Pig Dog Cat Cow Cat Cow Pig

Name of the file: test2.txt Contents: Cat Cow Pig Alpaca Hamster Dog Fish Rat Zebra Lion Cat Cow Pig Alpaca Rat Zebra Lion Cow Pig Alpaca Hamster Dog Fish

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!