top of page

Strings and Vectors/Arrays Assignment #2 Due: 9/6/2020 @11:59pm Last date for submission for partial credit on 9/9/2020 @11:59pm Vowel Statistics [Description] For this assignment, you will gather some small statistics about the number of vowels that are part of a vector of strings and an array of strings. At the highest level, you will gauge to see what are the differences between using an array versus using a vector in terms of the tiime it takes to complete the entire logic. For each container scenario, you will get the statistics of the number of vowels that are found in the entire array or vector. The total number of vowels will be displayed as the final output along with the time it took to complete the entire search for vowels. [ Deliverables ] You will create your own project and create three files shown below (you will do this via your IDE or doing this via command line; whichever way you choose): 1. Header file called: “vowel_stats.h” 2. A cpp file called: “vowel_stats.cpp” 3. A file called: “my_test.cpp:
When you are done creating your project and testing your code, the next thing you will need to do is to prepare the file above files need to be organized in the following manner: The top folder name should be formatted like HW2_CS144_<first_name>_<last_name>, and in this folder you should have another folder called “my_test”. All three source files need to be in this “my_test” directory. You will zip the folder: HW2_CS144_<first_name>_<last_name> such that the resulting zip file name is: HW2_CS144_<first_name>_<last_name>.zip i.e. HW2_CS144_Scooby_Doo.zip Please test the unzipping of this file before you submit it. When you practice unzipping the file i.e. unzipping it via double clicking the .zip or using a command line to unzip the file, ensure that the HW2_CS144_<first_name>_<last_name> folder is appearing and that the my_test folder exists in there and that it also has the three source files and screenshot files in there. **I will only the source files and your screenshot pictures. I will be using your files and will place them in my own project for testing. It is very important that you use the files name as mentioned above. Do not change or rename the files. Please keep all upper and lower cases letters as is. This also applies to the method names described above. [ About the files ] (A) The header file will declare the following methods:
1. void get_vector_stats(vector<std::string>vect); 2. void get_array_stats(std::string arr[], int arr_length); 3. void display_stats(); (B) The cpp file will implement the details in each body of each function that is declared in the header file. You will include the header file in the cpp file as well. All variables i.e. global etc. will be contained all within the cpp file. You can implement other supporting methods, but those methods should not be accessible to the my_test.cpp, nor should they be called in the my_test.cpp file. For the display_stats() method, show a list of vowels with the count, and followed by the total time it took to process the vowels. i.e. [ Vowel Statistics ] a: 2 e: 5 i: 7 o: 12 u: 15 Elapsed time => milliseconds: 2100ms, in seconds: 2.1s For the following methods: 1. void get_vector_stats(vector<std::string>vect); 2. void get_array_stats(string arr[])
you will implement the timers at the beginning and at the end of each method so that you can calculate the time differences. Please notes towards the end of this assignment description. In addition, if you are encountering challenges in calculating the array size of the get_array_stats() method, review ... see HINT on page 18 in the Week 2 part 1 slide, and make sure to check the length of the array before trying to use it in this method. (C) The my_test.cpp file will be the test driver that includes the header file, and the main which will call each of the three methods. Your test will use a standard set of inputs to be provided, and a set of your own choice of words in the array and in the vector; basically two separate tests because there will be two different inputs. In your main method you will create the vector and array variable that you will pass to the methods in the header. Those methods are: 1. void get_vector_stats(vector<std::string>vect); 2. void get_array_stats(string arr[], int arr_length) Note: There are some issues with getting the array length via the pointer arithmetic method which is depending on your compiler environment. So rather than to have to resolve more than one compiling environment issues, there is now a second parameter in the #2 method where your program will supply the array length of that string array. You must show the array length calculation using one of the two methods as discussed on Monday's lecture about calculating array lengths; this should be done at the scope level of the main() method.
So for your string creation, you will create the vector and array variable that will reference the words in both scenarios described below: Scenario #1: The standard set of strings will be: "Today will be a great day and many more to come!" Scenario #2: You will then come up with your own set of strings for additional testing. For the results, you must illustrate the results for both scenarios, and take a screenshot of both scenarios. ** If you recall, Assignment 1-D used a string vector in the helloworld.cpp file described in one of the Visual Studio Code links. You will create your variable to do just that but using the words in the sentence above. In the week 2 slides, there is also an example of how to create an array. Similarly can be done for creating an array of strings. Don't over complicate the initialization of the the string vector and string array as this initialization line should only be one line of code for the string vector and for the string array. [ NOTES - Exploring new topics ] Below is some information on how you can capture computer timed in milliseconds and in seconds. #include <iostream> #include <chrono> #include <ctime> #include <thread>
using namespace std; int main() { std::chrono::time_point<std::chrono::system_clock>start_time = std::chrono::system_clock::now(); std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::chrono::time_point<std::chrono::system_clock>end_time = std::chrono::system_clock::now(); // time in milliseconds double time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count(); double time_in_seconds = time_ms / 1000.0; cout<< "milliseconds: " <<time_ms<<endl; cout<< "seconds: " <<time_in_seconds<<endl; } [ Notes about comments ] Please comment your source code when necessary. Comment examples: int value_holder; // This is a single line comment /* This is a multi-line comment int tasks;
double value; */ [ Remember ] There will be one more additional file that will be part of the submission which will be a screenshot capturing your output from your IDE or terminal window; and so a total 4 or more files (the three source files and one or more screen shots) will be submitted by you. Again, these files should be saved in the “my_test” folder that is described above. Remember, when you submit the assignment, only submit one .zip file, and add any comments (if you wish) to the text entry field on submission for any explanations.

Strings and Vectors/Arrays Assignment #2(Solved)

$100.00 Regular Price
$90.00Sale Price
    bottom of page