I'm having some problems with a program that invovles arrays. I have a program that is suppose to read data from a file fish.txt about fisherman. The a function is suppose to print the number of fish that need to be thrown back because their is a maximum of 14 fish allowed. Then finally I need a function that is suppose to print the fisherman number with the most fish and how many they caught. Something is wrong with the math for the number of maximum fish and a problem with the fisherman who caught the most it goes through each one which and doesn't display their array number.
Any help would be appreciate it. Thank you.
#include <iostream>
#include <iomanip>
using namespace std;
void getData (int[]);
void throwback (int [], int);
void findMax (int[], int);
int main()
{
const int NUM_FISH=20;
int fish[NUM_FISH];
int badfish;
int max;
// print fish data
cout << "Fish Story Data\n"
<< "---------------\n";
for (int i=0; i < NUM_FISH; i++ )
{
cout << setw(2) << i << setw(6) << fish[i] << endl;
}
// read fish data
getData (fish);
throwback (fish, badfish);
findMax (fish, max);
return 0;
}
void getData (int fish [])
{
int NUM_FISH = 20;
for (int i=0; i < NUM_FISH; i++ )
{
// cout << "enter number of fish caught by person: " << i << " ";
cin >> fish[i];
}
}
void throwback (int fish [],int badfish)
{
int goodfish = 14;
int NUM_FISH = 20;
for (int i=0; i < NUM_FISH; i++ )
{
if(fish[i]>goodfish)
badfish=fish[i]-goodfish;
}
}
void findMax (int fish [], int max)
{
int NUM_FISH = 20;
max = 0;
for (int i=0; i<NUM_FISH; i++)
{
if (fish[i]>max)
max=fish[i];
cout<<"The maxmum number of fish caught was " <<max <<"by "
<<fish[i]<<endl;
}
}