//Matthew Santos     CS1A     Ch. 6, Pg. 370, #4
/***********************************************
 * 
 * FIND SAFEST DRIVING AREA
 * _____________________________________________
 * Determines which of the five regions is the
 * safest to drive in based off the amount of
 * accidents reported there in the last year.
 * _____________________________________________
 * INPUT
 *      north  : reported accidents in region north
 *      south  : reported accidents in region south
 *      east   : reported accidents in region east
 *      west   : reported accidents in region west
 *      central: reported accidents in region central
 * 
 * OUTPUT
 *      lowest : region with the lowest accidents
 ***********************************************/
#include <iostream>
#include <string>
using namespace std;
 
int getNumAccidents(string);
 
void findLowest(int, int, int, int, int);
 
int main() {
	//Initialize varibles
    int north = getNumAccidents("North");
    int south = getNumAccidents("South");
    int east = getNumAccidents("East");
    int west = getNumAccidents("West");
    int central = getNumAccidents("Central");
    int lowest;
 
    // Determine and display which region had the fewest accidents
    findLowest(north, south, east, west, central);
 
    return 0;
}
 
int getNumAccidents(string regionName) {
    int accidents;
    cout << "Enter the number of automobile accidents for the " << regionName << " region: ";
    cin >> accidents;
 
    // Input validation
    while (accidents < 0) {
        cout << "Accident number cannot be negative. Enter again for " << regionName << ": ";
        cin >> accidents;
    }
 
    return accidents;
}
 
void findLowest(int north, int south, int east, int west, int central) {
    int lowest = north;
    string region = "North";
 
    if (south < lowest) {
        lowest = south;
        region = "South";
    }
    if (east < lowest) {
        lowest = east;
        region = "East";
    }
    if (west < lowest) {
        lowest = west;
        region = "West";
    }
    if (central < lowest) {
        lowest = central;
        region = "Central";
    }
 
    cout << "\nThe region with the fewest accidents is " << region
         << " with " << lowest << " accidents." << endl;
}