Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming C++ programming Points: Due: LS ISO pose: Review of material from CS 135: Intro to data structures (stru 10 (drawings) + 25 (program)

C++ Programming image text in transcribed

C++ programming

Points: Due: LS ISO pose: Review of material from CS 135: Intro to data structures (stru 10 (drawings) + 25 (program) Prawings: 12 Noon, Sunday, January 26, in D2L's Project 1 Drawings dropbox. Program: 12 Noon on Friday, January 31, 2020, via the turnin utility. No late submissions accepted. Description: Print the first ption: Print the first 100 unique words found in a file, sorted, along with the number of occurrences of each word. skens, sorted, each this, do thel e his project, you will write a program that initially prompts the user for a file name. If the file is 10 found, an error message is outnut and the program terminates. Otherwise, the program inputs each token in the file, storing un to the first 100 unique ones found and prints the tokens, sorted, each ompanied by the number of times it appeared, in a well formatted manner. To accomplish all this, dow following: Open the file - the user must be prompted and a file name input.DO NOT hardcode a file name. Read the words in the file. placing them in alphabetical order in an array of struct with capacity 100, where each struct has a string (the word) and an int (number of occurrences). Report the results ->don Create cile You must write appropriate functions for each task. At minimum, you must write a function for each of the following: Open the file: O Pass in an ifstream (must be passed by reference [what type of parameter is it?]). The function prompts the user and, if the file is found, it returns true and the ifstream will be a handle for that text file. Otherwise the function returns false, and the argument is assumed to be undefined. Populate the array of struct with the words in the file: O Pass in three reference arguments, the ifstream, the 100 element array of word/count structs, and the count of elements in use in the array. When the function completes, the array will hold the words in the file, ordered. Search for a token: > O Pass in the array of struct (automatically by reference), its in-use count (by value), and a token (also by value). Return the index where the token was found, or, if not found, the index where failure could be established (see below). Output results: O Pass in the variables that hold the file name (for printing purposes), the array, and its in-use U count. Use this data to produce the desired output, which should be appropriately formatted. Increment the counter member of a struct that holds a word and its multiplicity: O Pass in a single struct; it will be an import/export parameter. Simply increment its counter A member Opening the file and printing the tokens with multiplicity are both straight-forward. Populating the array is a bit more complex, as the list is to be maintained in order at all times. 'For each token input, the populate function will call the search function to obtain the index where the token is to be placed. The cases for this are that the index returned by the search: 1. Equals the value of the array's in-use counter 2. Is of a struct holding a token equivalent to the token searched for 3. Is of a struct holding a token greater than the token searched for Points: Due: LS ISO pose: Review of material from CS 135: Intro to data structures (stru 10 (drawings) + 25 (program) Prawings: 12 Noon, Sunday, January 26, in D2L's Project 1 Drawings dropbox. Program: 12 Noon on Friday, January 31, 2020, via the turnin utility. No late submissions accepted. Description: Print the first ption: Print the first 100 unique words found in a file, sorted, along with the number of occurrences of each word. skens, sorted, each this, do thel e his project, you will write a program that initially prompts the user for a file name. If the file is 10 found, an error message is outnut and the program terminates. Otherwise, the program inputs each token in the file, storing un to the first 100 unique ones found and prints the tokens, sorted, each ompanied by the number of times it appeared, in a well formatted manner. To accomplish all this, dow following: Open the file - the user must be prompted and a file name input.DO NOT hardcode a file name. Read the words in the file. placing them in alphabetical order in an array of struct with capacity 100, where each struct has a string (the word) and an int (number of occurrences). Report the results ->don Create cile You must write appropriate functions for each task. At minimum, you must write a function for each of the following: Open the file: O Pass in an ifstream (must be passed by reference [what type of parameter is it?]). The function prompts the user and, if the file is found, it returns true and the ifstream will be a handle for that text file. Otherwise the function returns false, and the argument is assumed to be undefined. Populate the array of struct with the words in the file: O Pass in three reference arguments, the ifstream, the 100 element array of word/count structs, and the count of elements in use in the array. When the function completes, the array will hold the words in the file, ordered. Search for a token: > O Pass in the array of struct (automatically by reference), its in-use count (by value), and a token (also by value). Return the index where the token was found, or, if not found, the index where failure could be established (see below). Output results: O Pass in the variables that hold the file name (for printing purposes), the array, and its in-use U count. Use this data to produce the desired output, which should be appropriately formatted. Increment the counter member of a struct that holds a word and its multiplicity: O Pass in a single struct; it will be an import/export parameter. Simply increment its counter A member Opening the file and printing the tokens with multiplicity are both straight-forward. Populating the array is a bit more complex, as the list is to be maintained in order at all times. 'For each token input, the populate function will call the search function to obtain the index where the token is to be placed. The cases for this are that the index returned by the search: 1. Equals the value of the array's in-use counter 2. Is of a struct holding a token equivalent to the token searched for 3. Is of a struct holding a token greater than the token searched for

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finance The Role Of Data Analytics In Manda Due Diligence

Authors: Ps Publishing

1st Edition

B0CR6SKTQG, 979-8873324675

More Books

Students also viewed these Databases questions