Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a program that determines which of five geographic region within a major c

ID: 3632776 • Letter: W

Question

write a program that determines which of five geographic region within a major city north,north,east,west and central) had the fewest reported automobile accidents last year. it should have the following functions, which are called by main.

int getNumAccidents () is passes of the name of a region. it asks the user for the number of automobile accidents reported in that region during the last year, validates the input, then returns it. it should be called once for each city region.

void findLowest () is passed the five accident totals. it determines which is the smallest and prints the name of the region, along with its accident figure.


Input validations: Do not accept and accident number that is less than 0.
No system dependent commands such as "system "pause".
no header files in the solution to the problem on the answers. thanks. must be in function format

Explanation / Answer

please rate - thanks

#include <string>
#include <iostream>
using namespace std;
int getNumAccidents(string);
void findLowest(int[]);
int main()
{string region[]={"north","south","east","west","central"};
int i,accident[5];
for(i=0;i<5;i++)
   accident[i]=getNumAccidents(region[i]);

return 0;
}
int getNumAccidents(string r)
{int num=0;
do{
   cout<<"Enter number of accidents in the "<<r<<" region: ";
   cin>>num;
   if(num<0)
      cout<<"Invalid entry-reenter ";
   }while(num<0);  
return num;
}
void findLowest(int a[])
{string region[]={"north","south","east","west","central"};
int i,low,lowind=0;
low=a[0];
for(i=1;i<5;i++)
   if(a[i]<low)
      {low=a[i];
      lowind=i;
      }
cout<<" The region with the least accidents is the"<<region[lowind]<<" with "<<a[lowind]<<"accidents ";    
}