### Having trouble finding my errors.

I am trying to get this programming running to turn in for an assignment however I am banging my head against the wall at this point trying to figure out why I cannot get it to work properly... Any help would be greatly appreciated.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105`` ``````// Monthly Sales Analysis #include #include #include using namespace std; // Function Prototypes void inputData(double[]); int lowMonth(double[]); int highMonth(double[]); double averageSales(double[]); const char * monthArray[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; const int NUM_MONTHS = 12; int main() { double sales[NUM_MONTHS]; int low, high; double average; // Input the monthly sales data inputData(sales); // Find the month with the highest sales high = highMonth(sales); // Find the month with the lowest sales low = lowMonth(sales); // Calculate the average monthly sales average = averageSales(sales); // Display results cout << "The highest sales were in " << monthArray[high] << " with \$" << setprecision(2) << fixed << sales[high] << endl; cout << "The lowest sales were in " << monthArray[low] << " with \$" << setprecision(2) << fixed << sales[low] << endl; cout << "The average monthly sales were \$" << setprecision(2) << fixed << average << endl; cin.get(); cin.get(); cin.clear(); cin.ignore(255, '\n'); cin.get(); return 0; } // This functions requests the monthly sales data from the user void inputData( double sales[]) { for (int i = 0; i < NUM_MONTHS; i++) { cout << "Please enter the sales in dollars for " << monthArray[i] << " "; cin >> sales[NUM_MONTHS]; } return; } // This function determines which month had the highest sales and // returns the number for that month, 0 = January, 1 = February, etc. int highMonth(double sales[]) { int highest; highest = sales[0]; for (int i = 0; i < NUM_MONTHS; i++) { if (sales[i] > highest) highest = sales[i]; } return highest; } // This function determines which month had the lowest sales and // returns the number for that month, 0 = January, 1 = February, etc. int lowMonth(double sales[]) { int lowest; lowest = sales[0]; for (int i = 0; i < NUM_MONTHS; i++) { if (sales[i] < lowest) lowest = sales[i]; } return lowest; } // This function computes the average monthly sales double averageSales(double sales[]) { int sum = 0; double average = 0.0; for (int i = 0; i < NUM_MONTHS; i++) { sum += sales[i]; } return average = sum / NUM_MONTHS; }``````
Last edited on
@Angeljruiz: Fixed. Sorry my first post on here...
No problem :P Also whats a matter with it?
The main problem is that the functions for high and low are returning a 0 value. I believe it stems from a problem getting the CIN values into the sales[] but cannot seem to fix it.
When you get input you are always putting it into `sales[NUM_MONTHS]` when you should be putting `sales[i]`
Makes sense and I have tried that but when I do that I then get an Unhandled exception at line 38.
Its because in you high function you are setting highest to the highest dollars made, not the actual position. So lets say the highest sales was 5000, when you try to print it it would be sales[5000].