//Nathan Dominguez CSC5 Chapter 7, P.444 , #3
//
/*******************************************************************************
*
* Reprot Salsa Sales
* _____________________________________________________________________________
* This program reports and displays the sales for five different salsas.
*
* Computation is based on the formula:
* total sales = mild sales + medium sales + sweet sales + hot sales
* + zesty sales
*
* _____________________________________________________________________________
* INPUT
* jarsSold : Amount of jars sold for each salsa
*
* OUTPUT
* jars[] : Individual sales
* totalSales : Total sales of all salsas
* salsas[] : Displays highest and lowest selling salsas
*
**************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//Array List
string salsas[5] = {"Mild", "Medium", "Sweet", "Hot", "Zesty"};
int jars[5]; //INPUT - jars sold
int totalSales = 0; //How many jars were sold in total
int leastSold; //VALIDATE - assign a name to the least amount of
//jars sold
int mostSold; //VALIDATE - assign a name to the most amount of
//jars sold
int mostSalsa; //OUTPUT - name of highest selling salsa
int leastSalsa; //OUTPUT - name of lowest selling salsa
//
//loop program 5 times
for (int i = 0; i < 5; i++)
{
cout << "Enter number of jars sold for " << salsas[i] << ":" << endl;
cin >> jars[i];
//
//input validation for jars sold
if ( jars[i] < 0)
{
cout << "Error, enter a value greater than 0." << endl;
cout << "Enter number of jars sold for " << salsas[i] << ".";
cout << endl;
cin >> jars[i];
}
totalSales += jars[i];
}
leastSold = jars[0];
//input validation for most and least jars sold
for (int i = 0; i < 5; i++)
{
if (jars[i] > mostSold)
{
mostSold = jars[i];
mostSalsa = i;
}
if (jars[i] < leastSold)
{
leastSold = jars[i];
leastSalsa = i;
}
}
//output sales report
cout << "\t\t Sales Report" << endl;
for (int i = 0; i < 5; i++)
{
cout << salsas[i] << ".................." << jars[i] << " jars sold";
cout << endl;
}
cout << "Total.................." << totalSales << " jars sold" << endl;
cout << salsas[mostSalsa] << " was the highest selling salsa." << endl;
cout << salsas[leastSalsa] << " was the lowest selling salsa." << endl;
return 0;
}