//Ryan Robateau CSC5 Chapter 7, P. 444, #3
//
/*******************************************************************************
* Compute Chip and Salsa Sales
* _____________________________________________________________________________
* This program prompts the user for the number of jars sold
* for different types of salsas. The program then produces a
* report displaying sales for each salsa type, total sales,
* and the names of the highest selling and lowest selling
* products.
* _____________________________________________________________________________
******************************************************************************/
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
const int SALSA_TYPES = 5;
int jars[SALSA_TYPES]; // INPUT - Jars Sold
int jarsTotal; // OUTPUT - Total of all jars sold
int jarsMax; // OUTPUT - Most Jars sold
int jarsMin; // OUTPUT - Least Jars sold
int count;
string salsaNames[SALSA_TYPES] = { "Mild",
"Medium",
"Sweet",
"Hot",
"Zesty"};
string salsaMost = salsaNames[0];
string salsaLeast = salsaNames[0];
for (count = 0; count < SALSA_TYPES; count++)
{
cout << "Enter number of jars sold for " << salsaNames[count] << ":";
cout << endl;
cin >> jars[count];
while (jars[count] < 0)
{
cout << endl << "<ERROR: Please input a value greater than 0>";
cout << endl << endl;
cout << "Enter the number of jars for " << salsaNames[count]
<< ": " << endl;
cin >> jars[count];
}
}
for (count = 0; count < SALSA_TYPES; count++)
jarsTotal += jars[count];
jarsMax = jars[0];
for (count = 0; count < SALSA_TYPES; count++)
{
if (jars[count] > jarsMax)
{
jarsMax = jars[count];
salsaMost = salsaNames[count];
}
}
jarsMin = jars[0];
for (count = 0; count < SALSA_TYPES; count++)
{
if (jars[count] < jarsMin)
{
jarsMin = jars[count];
salsaLeast = salsaNames[count];
}
}
// OUTPUT RESULTS
cout << endl << "SALSA SALES" << endl;
cout << "---------------------" << endl;
for (count = 0; count < SALSA_TYPES; count++)
{
cout << left << setw(11) << salsaNames[count]
<< ": " << jars[count] << " jars" << endl;
}
cout << "Total sales: " << jarsTotal << " jars" << endl;
cout << "Highest selling salsa: " << salsaMost << endl;
cout << "Lowest selling salsa: " << salsaLeast;
return 0;
}