/******************************************************************************************
state.cpp
******************************************************************************************/
#include "state.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

//------- Generate an "OTHER PLACES" entry ------
void calculateOther(state list[], int& count, int total) {
    list[count].full = "Other States";
    list[count].count = total;
    list[count].percent = 1.0;
    for (int i = 0; i < count; i++) {
        list[count].count -= list[i].count;
        list[count].percent -= list[i].percent;
    }
    count++;
}

//------- fill state critera data from a file ------
void loadStates(string filename, state list[], const int maximum, int& size) {
    ifstream fin(filename.c_str());
    for (int i=0; i < maximum; i++) {
        if(fin >> list[i].full >> list[i].token)
            size++;
    }
}

//------- show all the results ------
void displayResults(state list[], const int count) {
    int i;
    for (i = 0; i < count; i++)
        cout << list[i].count << " records from "<< list[i].full << endl;
    cout << endl;

    for (i = 0; i < count; i++)
        cout << list[i].percent*100 << "% of records from "<< list[i].full << endl;
}