/******************************************************************************************
main.cpp
******************************************************************************************/
#include <iostream>
#include <string>
using namespace std;

#include "person.h"
#include "state.h"

// prototypes
void fullTally(state [], const int, person [], const int);

// MAIN!
void main() {
    int StateCount = 0;
    const int StateSize=50+1;
    state Tally[StateSize];

    string filename;
    cout << "Enter the file to read for STATE CRITERIA: ";
    cin >> filename;
    loadStates(filename, Tally, StateSize, StateCount);

    int count=0;
    const int maxsize=100;
    person census[maxsize];

    cout << "Enter the file to read for CENSUS DATA: ";
    cin >> filename;
    readFile(filename, census, maxsize, count);

    fullTally(Tally, StateCount, census, count);
    calculateOther(Tally, StateCount, count);
    displayResults(Tally, StateCount);
}

//------- do all the calculations ------
void fullTally(state criteria[], const int critCount, person data[], const int dataCount) {
    for (int i = 0; i < critCount; i++) {
        criteria[i].count = TallyByState(criteria[i].token, data, dataCount);
        criteria[i].percent = (float)criteria[i].count/dataCount;
    }
}