1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <iostream>
using namespace std;
//Function Prototypes
int getNumAccidents(int&, int&, int&, int&, int&);
void findLowest(int&, int&, int&, int&, int&);
void findHighest(int&, int&, int&, int&, int&);
int main()
{
int north, south, east, west, central;
//Call getNumAccidents to input the five numbers
getNumAccidents(north, south, east, west, central);
// call findLowest
//Display the highest and lowest
return 0;
}
int getNumAccidents(int &north, int &south, int &east, int &west, int ¢ral)
{
cout << "Enter number of accidents in North, South, East, West, and Central, in that order: ";
cin >> north >> south >> east >> west >> central;
if (north < 1 || south < 1 || east < 1 || west < 1 || central < 1)
{ cout << " Invalid input, please make sure all numbers are positive and more than 0.";
cin >> north >> south >> east >> west >> central;
}
return 0;
}
void getLowest(int &north, int &south, int &east, int &west, int ¢ral)
{
if (north < south && north < east && north < west && north < central)
cout << "North" << north;
else if (south < north && south < east && south < west && south < central)
cout << "South" << south;
else if (east < north && east < south && east < west && east < central)
cout << "East" << east;
else if (west < north && west < south && west < east && west < central)
cout << "West" << west;
else if (central < north && central < south && central < east && central < west)
cout << "Central" << central;
}
void getHighest(int &north, int &south, int &east, int &west, int ¢ral)
{
if (north > south && north > east && north > west && north > central)
cout << "North" << north;
else if (south > north && south > east && south > west && south > central)
cout << "South" << south;
else if (east > north && east > south && east > west && east > central)
cout << "East" << east;
else if (west > north && west > south && west > east && west > central)
cout << "West" << west;
else if (central > north && central > south && central > east && central > west)
cout << "Central" << central;
}
|