For this program you will need to run tests. As you did in the last two labs, create CSV (comma separated value) lists of test data and read it in to test your programs. You can use AI to write the program to generate test data. You can also use AI to write the program to do the tests. You should promt AI for the test program, and refine it until it is something close. Then you should edit it to be exactly what you want.
Part I
Do programming exercises 3, 4, 5, and 6 at the end of chapter 4. Write a single test program for all of these tasks but make sure you test each function/task separately and fully, and provide the user a good interface (that should include the option of repeating computations). Some hints:
- The algorithm library contains a generic
swapfunction. You may want to use it for # 4. (To use it insert #include <algorithm>) - For #4, If you are going to use iterators (you don’t have to), then the beginning of the
reverseVectorfunction should be like this
template < class elemType>
void reverseVector(vector<elemType> &list)
{
typename vector<elemType>::iterator Itr1,Itr2;
..... FILL IN THE REST
}Code language: HTML, XML (xml)
I actually didn’t use iterators, I found it easier without them.
From the textbook:
3. Write a program that uses a vector object to store a set of real numbers. The program outputs the smallest, largest, and average of the numbers. When declaring the vector object, do not specify its size. Use the function push_back to insert elements in the vector object.
4. Write the definition of the function template reverseVector to reverse the elements of a vector object.
template void reverseVector(vector &list);
//Reverses the elements of the vector list.
//Example: Suppose list = {4, 8, 2, 5}.
// After a call to this function, list = {5, 2, 8, 4}.Code language: JavaScript (javascript)
Also, write a program to test the function reverseVector. When declaring the vector object, do not specify its size. Use the function push_back to insert elements in the vector object.
5. Write the definition of the function template seqSearch to implement the sequential search on a vector object.
template<class elemtype>
int seqSearch(const vector &list, const elemType& item);
//If item is found in the list, returns the
//position of the item in the list; otherwise, returns -1.Code language: JavaScript (javascript)
Also, write a program to test the function seqSearch. Use the function push_back to insert elements in the vector object. 6. Write a program to find the mean and standard deviation of numbers. The mean (average) of n numbers x1, x2, . . ., xn is (x1 + x2 + … + xn) / n. The standard deviation of these numbers is as follows:

Part II
Write a program that uses the map template class from STL to compute a histogram of positive numbers entered by the user. The map’s key should be the number that is entered, and the value should be a counter of the number of times the key has been entered so far. Use -1 as a sentinel value to signal the end of user input. For exampe, if the user inputs:
5,12,3,5,5,3,21
then the program should output the following (not necessarily in this order):
The number 3 occurs 2 times.
The number 5 occurs 3 times.
The number 12 occurs 1 times.
The number 21 occurs 1 times.
The program should let the user enter as many (multi)sets of numbers as they want.
Grading
| Requirements | Grading Comments | Points | Score |
|---|---|---|---|
| Good Code Design | 30 | ||
| Test suite for all functions including common and boundry cases. | 20 | ||
| All required function implemented | 20 | ||
| User Interface for selecting and running tests | 20 | ||
| Comments | 10 | ||
| Total | 100 |
Teams:
Lab4-Pair-01 — Cohen, Eden H. (cohen10@kenyon.edu), Deka, Calvin (deka1@kenyon.edu)
Lab4-Pair-02 — Liu, Joey (liu17@kenyon.edu), Galik, Luke (galik1@kenyon.edu)
Lab4-Pair-03 — Nguyen, Hoa (nguyen15@kenyon.edu), Xie, Leo (xie4@kenyon.edu)
Lab4-Pair-05 — Dunson, Peter (dunson1@kenyon.edu), Ampofo-Twumasi, Davelle (ampofotwumasi1@kenyon.edu)
Lab4-Pair-06 — Vasconez, Danny (vasconez1@kenyon.edu), Archer, Nora (archer1@kenyon.edu)
Lab4-Pair-07 — Belghith, Moe (belghith1@kenyon.edu), Kailus, Kelly (kailus1@kenyon.edu)
Lab4-Pair-08 — Sintayehu, Sariyah A (sintayehu1@kenyon.edu), Rigoli, Ella (rigoli1@kenyon.edu)
Lab4-Pair-09 — Oppong-Krampah, Yaw (oppongkrampah1@kenyon.edu), Dragojlovic, Dordje (dragojlovic1@kenyon.edu)
Lab4-Pair-10 — Aguad, Amado (amadoaguad1@kenyon.edu), Nguyen, Trang (nguyen7@kenyon.edu)
Lab4-Solo-01 — Kopczuk, Kuba (kopczuk1@kenyon.edu)
Lab4-Solo-02 — Khan, Adam (khan1@kenyon.edu)
Lab4-Solo-03 — Mai, Khanh (mai1@kenyon.edu)
