hw7_main.cpp

/* Programmer: Jennifer Leopold

Date: October 13, 2016

File: hw7_main.cpp

Purpose: Program that creates a database of trash piles

and a database of offenders. Shows user worst

offenders, offenders who contribute high percentage

of trash, and offender who likely created a

particular trash pile.

To compile: fg++ hw7_main.cpp hw7_functs.cpp -o hw7

To execute: ./hw7

*/

#include <iostream>

#include <ctime>

#include <cstdlib>

#include "hw7_functs.h"

using namespace std;

int main()

{

trashPile trashDB[NUM_DB_ENTRIES]; // Wiggum's trash pile DB

offender offenderDB[NUM_DB_ENTRIES]; // Lisa's offender DB

// Seed the random number generator

srand(time(NULL));

// Greet the user

greeting();

// Create the trash and offender databases

createTrashDB(trashDB, NUM_DB_ENTRIES);

createOffenderDB(offenderDB, NUM_DB_ENTRIES);

// Sort and print out the contents of both databases

sortArray(trashDB, NUM_DB_ENTRIES);

printTrashPiles(trashDB, NUM_DB_ENTRIES);

sortArray(offenderDB, NUM_DB_ENTRIES);

printOffenders(offenderDB, NUM_DB_ENTRIES);

// Output the 2 guiltiest offenders

cout << "\nTwo guiltiest offenders are:\n";

printOffender(offenderDB[0]);

printOffender(offenderDB[1]);

// Determine and output the offenders who contribute

// a certain percentage of the trash

findContributorsOfMostTrash(trashDB, NUM_DB_ENTRIES,

offenderDB);

// Output the total weight in each sector

cout << "\nTotal weight in each sector:\n";

printTrashBySector(trashDB, NUM_DB_ENTRIES);

// Let user query the databases by specifying a particular

// trash pile, then outputting the most likely offender

// responsible for it

findOffenderByTrashPile(trashDB, NUM_DB_ENTRIES,

offenderDB);

// Sign-off

signOff();

return 0;

}