Once I completed the following code, compiled.....this is what displayed: Number of 'mild' jars sold. (That's it). Is there something wrong with my C-prompt? Did I miss something? the code is sappose to:
Prompt the user to enter the number of jars sold for each type. Once this sales data has been entered, the program should produce
a report that displays sales for each salsa type, total sales, and the names of the highest selling and lowest selling products. See code:
//This program lets a maker of chips and salsa keep track of sales
#include <iostream>
#include <string>

using namespace std;
int findMin(int array[])
{
int min = array[0];
int i, index = 0;
for(i = 0; i<5; i++)
{
if(array<min)
{
index = i;
min = array;
}
}
return index;
}
int findMax(int array[])
{
int max = array[0];
int i, index = 0;
for(i = 0; i<5; i++)
{
if(array>max)
{
index = i;
max = array;
}
}
return index;
}
int main()
{
string salsa[] = {"mild", "medium", "sweet", "hot", "zesty"};
int jars_sold[5];
int total_sale = 0;
int index, i;
cout<<"Number of 'mild' jar sold\t: ";
cin>>jars_sold[0];
cout<<"Number of 'medium' jar sold\t: ";
cin>>jars_sold[1];
cout<<"Number of 'sweet' jar sold\t: ";
cin>>jars_sold[2];
cout<<"Number of 'hot' jar sold\t: ";
cin>>jars_sold[3];
cout<<"Number of 'zesty' jar sold\t: ";
cin>>jars_sold[4];

cout<<"\n\nReport\n";
cout<<"------\n";
for(i = 0; i<5; i++)
{
cout<<jars_sold<<" "<<salsa<<" jars sold"<<endl;
total_sale += jars_sold;
}
cout<<"\nTotal jar sold : "<<total_sale<<endl<<endl;
index = findMin(jars_sold);
cout<<"\nLowest selling salsa is (are) : "<<endl;
for(i = 0; i<5; i++)
{
if(jars_sold == jars_sold[index])
cout<<salsa<<endl;
}
index = findMax(jars_sold);
cout<<"\nHighest selling salsa is (are) : "<<endl;
for(i = 0; i<5; i++)
{
if(jars_sold == jars_sold[index])
cout<<salsa<<endl;
}
return 0;
}

What went wrong?

Recommended Answers

All 6 Replies

Try entering a number and pressing enter.

Thanks...That would help wouldn't it.

AnG'

Try entering a number and pressing enter.

Did it work? I would assume it did, all you had to do was enter a number to cin :lol:

your code is fine man.. I enter 5 numbers (one for each type) and the output seems correct to me. Dont know what went wrong on your side?!?...

It did....Thanx a bunch. I guess I'm coding 2hard!

S-L-O-W.....Thanx...I simply forgot!! Appreciate the help!!

Yes it worked. Thanx again!!

AnG'

Please don't post the same thank you three times :rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.