Hello codeguru family,

I am a student and my professor gave our a class a programming project where we declare two arrays, a sting array containing the names of the boroughs and an int array which which holds accident number for each borough. The main function calls getNumAccidents() function to fill the array. it then calls findLowest() to learn which borough had the fewest accidents. It should print out the accident numbers for each borough and then out the borough and accident number with the fewest accidents.

I'm able to get the program to kind of work. When I run it everything works fine but I am not able to get the arrays to sort and match up correctly..

Please look at the code below. and remember I still pretty new at this..




#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
using namespace std;

class combineSort
{

public:
combineSort()
{
borough[0]="New York City";
borough[1]="Bronx";
borough[2]="Queens";
borough[3]="Brooklyn";
borough[4]="Manhattan";
}
string borough[5];
int accident;
int temp;
};

const int SIZE = 5;
int getNumAccidents(combineSort[], combineSort[]);
int findLowest(combineSort[],combineSort[]);

/*********main*******/

int main()
{
combineSort custom[SIZE];
int j;
getNumAccidents(custom, custom);
findLowest(custom,custom);
return 0;
}

int getNumAccidents(combineSort[], combineSort custom[])
{
{ //New York City
cout<<"\nEnter Number of Accidents for "<<*(custom[0].borough)<<endl;
cin>>custom[0].accident;
if(custom[0].accident<0)
{
cout<<"Number has to be greater than 0";
return 0;
}
//Borough of the Bronx
cout<<"\nEnter Number of Accidents for "<<*(custom[0].borough+1)<<endl;
cin>>custom[1].accident;
if(custom[1].accident<0)
{
cout<<"Number has to be greater than 0";
return 0;
}
//Borough of Queens
cout<<"\nEnter Number of Accidents for "<<*(custom[0].borough+2)<<endl;
cin>>custom[2].accident;
if(custom[2].accident<0)
{
cout<<"Number has to be greater than 0";
return 0;
}
//Borough of Brooklyn
cout<<"\nEnter Number of Accidents for "<<*(custom[0].borough+3)<<endl;
cin>>custom[3].accident;
if(custom[3].accident<0)
{
cout<<"Number has to be greater than 0";
return 0;
}
//Borough of Manhattan
cout<<"\nEnter Number of Accidents for "<<*(custom[0].borough+4)<<endl;
cin>>custom[4].accident;
if(custom[4].accident<0)
{
cout<<"Number has to be greater than 0";
return 0;
}


}
}
//sort to find the lowest accident
int findLowest(combineSort custom[],combinesort custom[])
{
int temp;

for(int i=0;i<5;i++){
if(custom[i].accident<custom[0].accident){
custom[i].temp=custom[i].accident&&*(custom[i].borough);
accident&&*(custom[i].borough)=accident&&*(custom[i].borough);
accident&&*(custom[i].borough)=custom[i].temp;
}
}
cout<<"The lowest number of accident is: "<<custom[0].accident<<endl;
cout<<"In the Borough of: "<<*custom[0].borough<<endl;
return 0;

}