#include <iostream> #include <string> using namespace std; int getNumAccidents(string); int findLowest(int [], string[]); int main() { string borough[5]; int accident[5]; borough[0] = "Brooklyn"; borough[1] = "Manhatten"; borough[2] = "Staten Island"; borough[3] = "Queens"; borough[4] = "Bronx"; int i; for (i = 0; i < 5; i++) accident[i] = getNumAccidents(borough[i]); findLowest(accident [5], borough [5]); system("PAUSE"); } int getNumAccidents(string borough){ int accidents; cout << "Enter amount of accidents in " << borough << endl; cin >> accidents; if (accidents < 0){ cout << "Number must be higher than 0, please try again." << endl; cin >> accidents; } return accidents; } int findLowest(int accident[5], string borough[5]){ int temp, q = 0; string nemp; temp = accident[0]; nemp = borough [0]; for (q = 0; q < 5; q++){ if (accident[q] < temp){ temp = accident[q]; nemp = borough[q]; } cout << "The borough with the lowest amount of accidents is:" << endl << temp << "with " << nemp << endl; } |
|
|
|
|
|
|