So I've been neglecting my C++ class as of late. I know there are programmers here so what the hell, right.
The task is to set up a program in with five regions in a city. Accident data in input and the program will tell the user which area has the lowest amount of accidents.
This is as far as I've gotten. The MS Visual Studio says that there are undeclared identifiers, crashN, crashS, crashS, crashW, and crashC. Any help is appreciated. Remember, I'm a beginner who's just learned about the call function. I can't use things we haven't learned yet, for obvious reasons. Thanks in advance.
Program:
include
include
using namespace std; const int NORTH = 0; const int SOUTH = 1; const int EAST = 2; const int WEST = 3; const int CENTRAL = 4; int getNumAccidents(int); //argument denotes area void findLowest(int,int,int,int,int);
int main() { crashN = getNumAccidents(NORTH); crashS = getNumAccidents(SOUTH); crashE = getNumAccidents(EAST); crashW = getNumAccidents(WEST); crashC = getNumAccidents(CENTRAL);
findLowest(crashN,crashS,crashE,crashW,crashC);
system("PAUSE"); return 0; } int getNumAccidents(actionRegion) { cout << "Number of accidents in the "; switch (actionRegion) { case NORTH : cout << "North area"; break; case SOUTH : cout << "South area"; break; case EAST : cout << "East area"; break; case WEST : cout << "West area"; break; case CENTRAL : cout << "Central area"; break; } cin >> crashes; while (crashes < 0) { cout << "Enter a positive number"; cin >> crashes; }
return crashes
}