1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#ifndef H_statList
#define H_statList
#include <iostream>
#include <cassert>
#include <cstdlib>
using namespace std;
class statList
{
public:
bool isEmpty() const; /* *WRITTEN* */
//Function to determine whether the list is empty.
//Postcondition: Returns true if the list is empty,
// otherwise it returns false.
bool isFull() const; /* *WRITTEN* */
//Function to determine whether the list is full.
//Postcondition: Returns true if the list is full,
// otherwise it returns false.
int getLength()const; /* *WRITTEN* */
//Function to return the number of elements in the list.
//Postcondition: The value of length is returned.
int getMaxSize() const; /* *WRITTEN* */
//Function to return the maximum number of elements
//that can be stored in the list.
//Postcondition: The value of maxSize is returned.
void sort(); /* *WRITTEN* */
//Function to sort the list.
//Postcondition: The list elements are in ascending order.
void print() const; /* *WRITTEN* */
//Outputs the elements of the list.
void insertAt(const double& item, int position); /* *WRITTEN* */
//Function to insert item in the list at the location
//specified by position.
//Postcondition: list[position] = item; length++;
// If position is out of range, the program
// is aborted.
void insertInOrder(const double& item); /* *WRITTEN* */
//Function to insert item in the list at the location
//found to be appropriate by scanning the array.
//Use insertAt() once the position is found.
//Postcondition: list[position] = item; length++;
// If position is out of range, the program
// is aborted.
double getMean() const; /* *WRITTEN* */
//Function to sum the list, then divide the sum by the length
//to calcukate and store the mean.
//Postcondition: mean is stored.
double getMedian() const; /* *WRITTEN* */
//Function to sort the list, then find the median by finding
//the middle element. If the number of list items is even,
//then the mean of the two middle items is calculated.
//Postcondition: median is stored.
double getStdDev() const; /* *WRITTEN* */
//Function to getnthe mean, using getMean(), and use the
//following definition of Sample Standard Deviation to compute
//it via a for loop.
//Definition: Standard Deviation =
//sqrt((1/N)sum[1:N]((x[i]-average)*(x[i]-average)))
/*HINT: the summation is accomplished by the for loop.*
*So sum the square of the differences, then, after the*
*loop is executed, divide and take the square root. */
//Postcondition: sample standard deviation is stored.
void readInList(ifstream& infile); /* *WRITTEN* */
//Function to read items into the list.
//A designated input file will be read to EOF, and the values
//stored in the list for later analysis.
//Postcondition: The list is populated.
void find_index(const double& item);
void printLength(int& newLength);
void unsortList(); /* *WRITTEN* */
//test function to put the list in an unordsered state for test purposes.
//Postcondition: The list has the same elememnts, but is unsorted.
statList(int listSize=50); /* *WRITTEN* */
//Constructor
//Creates an array of double of the size specified by the
//parameter listSize; the default array size is 50.
//Postcondition: list contains the base address of the
// array; length = 0; maxsize = listSize;
// the array is initialized.
~statList(); /* *WRITTEN* */
//Destructor
//Deletes all the elements of the list.
//Postcondition: The array list is deleted.
private:
int maxSize; //variable to store the maximum size
//of the list
int length; //variable to store the number of elements
//in the list
double list[]; //pointer to the array that holds the
//list elements
};
#endif
|