Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a proram in c++ that does the following: Here is the IndexOfList files:

ID: 3802321 • Letter: D

Question

Develop a proram in c++ that does the following:

Here is the IndexOfList files:

/ File IndexList.h

#ifndef INDEXLIST_H
#define INDEXLIST_H
#include <iostream>
using namespace std;

template <class T, int maxSize>
class indexList
{
public:
   // Constructor
   indexList();

// Sort an indexed list
   void selSort();

   // Read data into the list
   void read(istream &);

   // Display the list contents
   void display() const;

   // Get the current size
   int getSize() const;

private:
   //Data Members
   T elements[maxSize];
   int size;
};

#endif // INDEXLIST_H

// File: IndexList.cpp
// Indexed list class implementation

#include "IndexList.h"
#include <iostream>
using namespace std;

template <class T, int maxSize>
indexList<T, maxSize>::indexList()
{
   size = 0;       // list is empty
}

template <class T, int maxSize>
void indexList<T, maxSize>::read(istream& ins)
{
   int numItems;
   T nextItem;

   cout << "Enter number of list items to read: ";
   ins >> numItems;

   size = 0;
   if (numItems >= 0 && numItems <= maxSize)
       while (size < numItems)
       {
           cout << "Enter next item - ";
           ins >> nextItem;
           elements[size] = nextItem;
           size++;
       }
   else
       cerr << "Number of items " << numItems
       << " is invalid"
       << " - data entry is cancelled!" <<
       endl;
}

// Display the list contents
// Pre: none
// Post: Displays each item stored in the list
template <class T, int maxSize>
void indexList<T, maxSize>::display() const
{
   // Display each list element.
   for (int i = 0; i < size; i++)
       cout << elements[i] << endl;
}
// Find index of a target item
// Pre: none
// Post: Returns the index of target if found;
// otherwise, return -1.

template <class T, int maxSize>
int indexList<T, maxSize>::search(const T&
   target) const
{
   for (int i = 0; i < size; i++)
       if (elements[i] == target)
           return i;
   // target not found
   return -1;
}


// Get the current size
template <class T, int maxSize>
int indexList<T, maxSize>::getSize() const
{
   return size;
}
// Sort the indexed list
template <class T, int maxSize>
void indexList<T, maxSize>::selSort()
{
   // Selection sort
}

The goal of this project is to create and manipulate an indexed list of employees. The class employee has two data members: the name and phone number of an employee, and four member functions setName C), displayName setPhone C) and displayPhone The template class indexList is posted on UR Courses (see lecture notes). In the class index List, include only the member functions that you need for this project. Write a driver program that will create an object, called myEmployeeList, which is an indexed list of N employees. The driver will also sort the employee list using the selection sort algorithm and display the sorted list. The selection sorting algorithm should be implemented in the template class indexList A sample run follows. List of type "Employee" Enter number of employees: 3 Enter next name: Sam Enter next phone number: 555-0000 Enter next name: Brenda Enter next phone number: 888-0000 Enter next name: Matt Enter next phone number: 333-0000

Explanation / Answer

#ifndef INDEXLIST_H
#define INDEXLIST_H
#include <iostream>
using namespace std;

template <class T, int maxSize>
class indexList
{
public:
   // Constructor
   indexList();

// Sort an indexed list
   void selSort();

   // Read data into the list
   void read(istream &);

   // Display the list contents
   void display() const;

   // Get the current size
   int getSize() const;

private:
   //Data Members
   T elements[maxSize];
   int size;
};

#endif // INDEXLIST_H

// File: IndexList.cpp
// Indexed list class implementation

#include "IndexList.h"
#include <iostream>
using namespace std;

template <class T, int maxSize>
indexList<T, maxSize>::indexList()
{
   size = 0;       // list is empty
}

template <class T, int maxSize>
void indexList<T, maxSize>::read(istream& ins)
{
   int numItems;
   T nextItem;

   cout << "Enter number of list items to read: ";
   ins >> numItems;

   size = 0;
   if (numItems >= 0 && numItems <= maxSize)
       while (size < numItems)
       {
           cout << "Enter next item - ";
           ins >> nextItem;
           elements[size] = nextItem;
           size++;
       }
   else
       cerr << "Number of items " << numItems
       << " is invalid"
       << " - data entry is cancelled!" <<
       endl;
}

// Display the list contents
// Pre: none
// Post: Displays each item stored in the list
template <class T, int maxSize>
void indexList<T, maxSize>::display() const
{
   // Display each list element.
   for (int i = 0; i < size; i++)
       cout << elements[i] << endl;
}
// Find index of a target item
// Pre: none
// Post: Returns the index of target if found;
// otherwise, return -1.

template <class T, int maxSize>
int indexList<T, maxSize>::search(const T&
   target) const
{
   for (int i = 0; i < size; i++)
       if (elements[i] == target)
           return i;
   // target not found
   return -1;
}


// Get the current size
template <class T, int maxSize>
int indexList<T, maxSize>::getSize() const
{
   return size;
}
// Sort the indexed list
template <class T, int maxSize>
void indexList<T, maxSize>::selSort()
{
   // Selection sort
}