0

I have to create a program with parallele arrays that recieves information from a file telling it how many salsas their are (their can't be more than 10). One array containts the name of the salsa, the other array contains the number of salsa jars sold. Then I have to print the data. I'm not sure why but I keep having alot of problems. If anyone could help me out I would appreciate it.

Thanks, ACRobison02

#include <iostream>
using namespace std;

int getSalsaData (string [], int[]);
void DisplaySalsa (string [], int []);

int main ()
{
const int max = 10;
string salsa[max];
int numsold[max];
int numsalsa;

numsalsa=getSalsaData (salsa, numsold);
DisplaySalsa (salsa, numsold);

return 0;
}

int getSalsaData(string salsa[max], int numsold [max])
{
  int numsalsa;
  cin>>numsalsa;

     for (int k=0; k<max; k++)
     {
     cin>>salsa[k];
     cin>>numsold[k];
     }
return numsalsa;
  }

void DisplaySalsa(string salsa[max], int numsold[max])
{
  cout<<"Salsa Type      Jars Sold " <<endl;

  for (int k=0; k<max; k++)
     {
     cin>>salsa[k];
     cin>>numsold[k];
     }
}
5
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by cikara21
0

>> I'm not sure why but I keep having alot of problems.
What are the problems? Error messages? compiler you are using? Operating system ?

0
void DisplaySalsa(string salsa[], int numsold[])
{
  cout<<"Salsa Type      Jars Sold " <<endl;

  for (int k=0; k<max; k++)
     {
     cout<<"salsa["<<k<<"] = "<<salsa[k]<<endl;
     cout<<"numsold["<<k<<"] = "<<numsold[k]<<endl;
     }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.