Sorry the subject is hard to read I had to fit it all in there briefly but so in this external function getNumAccidents I need to read in the user-input number of accidents for each NYC borough to be stored in their respective array places, but also validate the input within the external function as obviously any number of accidents needs to be a positive integer, so if it's not I need to return to the beginning of the function I guess, which I can't figure out how to do really, I've tried if() and do/while and crap, but none of it's worked and in the end I just don't know. Then I need to store the returned values into another corresponding array in the main function, to be called by another function findLowest, which is passed the five accident totals [as an array of ints] and determines which is the smallest and returns the subscript for that array element.
Here's what I have (super basic... I know...):
#include <iostream>
#include <iomanip>
using namespace std;
int getNumAccidents (string);
int findLowest (int arr[]);
int main()
{
string Boroughs[5] = {"Bronx", "Brooklyn", "Manhattan", "Queens", "Staten Island"};
int numAccidents[5];
for (int i=0; i<5; i++)
{
numAccidents[i] = 0;
cout << Boroughs[i] << "\t";
getNumAccidents(Boroughs[i]);
numAccidents[i] = getNumAccidents(Boroughs[i]);
cout << endl;
}
return 0;
}
int getNumAccidents (string instance)
{
int num = 0;
cin >> num;
return num;
}
int findLowest (int arr[])
{
}
Thanks