The instructions are to find the region with the lowest accidents.. my issue is what if there are entries with the same value. How do I get it to tell me there are more than one region with the lowest number?
#include <iostream>
#include <iomanip>
using namespace std;
int getNumAccidents();
void findLowest(int n, int s, int e, int w, int c);
int main()
{
// Safest Driving Area
cout << "Please enter the number of automobile accidents last year in north; ";
double north = getNumAccidents();
cout << "Please enter the number of automobile accidents last year in south; ";
double south = getNumAccidents();
cout << "Please enter the number of automobile accidents last year in east; ";
double east = getNumAccidents();
cout << "Please enter the number of automobile accidents last year in west; ";
double west = getNumAccidents();
cout << "Please enter the number of automobile accidents last year in central; ";
double central = getNumAccidents();
findLowest (north, south, east, west, central);
return 0;
}
int getNumAccidents()
{
int num;
cin >> num;
for (;num<0;)
{
cout << "Do not accept an accident number that is less than 0.\n "Please enter again: ";
cin >> num;
}
return num;
}
void findLowest(int n, int s, int e, int w, int c)
{
if (n<s && n<e && n<w && n<c)
{
cout << "North had the fewest reported automobile accidents last year for " <<n<<endl;
}
if (s<n && s<e && s<w && s<c)
{
cout << "South had the fewest reported automobile accidents last year for " <<s<<endl;
}
if (e<s && e<n && e<w && e<c)
{
cout << "East had the fewest reported automobile accidents last year for " <<e<<endl;
}
if (w<s && w<e && w<n && w<c)
{
cout << "West had the fewest reported automobile accidents last year for " <<w<<endl;
}
if (c<s && c<e && c<n && c<w)
{
cout << "Central had the fewest reported automobile accidents last year for " <<c<<endl;
}
}