hey i need help with writing a program where it lets a maker of chips and salsa keep track of sales...i have this so far but dont know what else to do.

# include <iostream>
# include <iomanip>

using namespace std;

int getTotal (int [], int);

int posOfLargest (int [], int);

int posOfSmallest(int [], int);

int main()

{

const int SIZE = 10;

const int NUM_TYPES = 5;

char name[NUM_TYPES] [SIZE] = {"mild", "medium", "sweet", "hot", "zesty"};

int sales[NUM_TYPES];

int totalJarsSold;

int hiSalesProduct;

int loSalesProduct;

for (int type = 0 ; type < NUM_TYPES ; type++ )

{

cout << "Jars sold last month of " << name[type] << ": " ;

cin >> sales[type] ;

while (sales[type] < 0 )

{ cout << "Jars sold must be 0 or more. Please re-enter: ";

cin >> sales[type];

}

}

cout << endl << endl ;

cout << " Salsa Sales Report \n\n";

cout << "Name Jars Sold \n";

cout << "______________________________\n";

for (int salsaType = 0 ; salsaType < NUM_TYPES; salsaType++)

{

cout << name[salsaType]

<< setw(21) << sales[salsaType]

<< endl;

}

cout << "\nTotal Sales:" << setw(15) << totalJarsSold << endl;

cout << "High Seller: " << name[hiSalesProduct] << endl;

cout << "Low Seller: " << name[loSalesProduct] << endl;

return 0;

}

int gettotal(int sales [], int SIZE) {

int total = 0 ;

int i;

for (i=0; i < SIZE ; i++){

total = total + sales[i];

}

return total ;

}

int getposOfLargest(int sales [], int SIZE){

int Largest=0;

int i;

for (i=1; i < SIZE ; i++){

if (sales[i] > sales[Largest])

Largest = i ;

}

return Largest;

}

int getposOfSmallest(int sales[], int SIZE) {

int Smallest = 0 ;

int i ;

for (i=1 ; i < SIZE ; i++) {

if (sales[i] < sales[Smallest])

Smallest = i ;

}

return Smallest ;

}

Edited 6 Years Ago by WaltP: Added CODE Tags

What does the program do as opposed to what it's supposed to do?

Are you getting any errors?

Also you should probably use code tags: paste your code between tags like these, without spaces [/code ].[code ]paste your code between tags like these, without spaces [/code ].

Edited 6 Years Ago by MyrtleTurtle: n/a

i keep getting this error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

it also says uninitialized local variable 'hiSalesProduct' used
uninitialized local variable 'loSalesProduct' used

Your program compiled for me (Dev-C++) but froze after printing the total sales.
I'm not sure about error LNK2019 (it didn't give me that error), but you can solve the other one by initializing your variables :

int totalJarsSold=0;
//do the same for the rest of them

Also, this looks like a 2-D array to me. It seems to work, though I guess you could use a string type? I don't know, maybe it's just a matter of preference?

char name[NUM_TYPES] [SIZE] = {"mild", "medium", "sweet", "hot", "zesty"};

//or
string name[NUM_TYPES] = {"mild", "medium", "sweet", "hot", "zesty"};

thanks the int worked but then it still says

1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

This article has been dead for over six months. Start a new discussion instead.