string array input problem
Why won't this let me input data from the keyboard for the species string array?
Code:
int main (void)
{
//declare arrays
int Length[numberFish];
int Weight[numberFish];
string Species[numberFish];
//declare
int l=0, w=0, s=0, t=0;
int numberFish=0;
cout<<"Enter number of fish:"<<endl;
cin>>numberFish;
//get input
for (s=0;s<numberFish;s++;w=0;w<numberFish;w++;l=0;l<numberFish;l++)
{
cout<<"Enter species:"<<endl;
cin.getline(Species,s);
cout<<"Enter weight in ounces:"<<endl;
cin>>Weight[w];
cout<<"Enter length in inches:"<<endl;
cin>>Length[l];
}
return EXIT_SUCCESS;
}
Heare's what I'm supposed to do:
read in a number of values representing length, species and wight of fish
read in all values then deermine average weights, minimum and maximun number of fish sampled for each species
end of data marked by negative length
output should be in tabular form
must use arrays
HERE'S MY CODE SO FAR:
Code:
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>
using namespace std;
//Project 4
//Amy E Peabody
//March 23, 2003
int main (void)
{
//declare
int l=0, w=0, s=0;
int numberFish=0;
int aveweight=0, totalweight=0;
//declare arrays
int Length[10];
int Weight[10];
string Species[10];
cout<<"Enter number of fish:"<<endl;
cin>>numberFish;
//get input
for (l=0;l<numberFish;l++)
{
cout<<"Enter species of each fish, length in inches and weight in ounces:"<<endl;
cin>>Species[s]>>Length[l]>>Weight[w];
w++;
s++;
}
//total and average weight
int t;
for (t=0;t<10;t++)
{
totalweight+=Weight[t];
aveweight=totalweight/t;
}
//max and min lengths
int maxLength=Length[0];
int minLength=Length[0];
for(l=0;l<10;l++)
{
if (Length[l]<maxLength){
maxLength=Length[l];
}
if (Length[l]<minLength){
minLength=Length[l];
}
}
return EXIT_SUCCESS;
}