// Andres Guzman CSC5 Chapter 7, P. 444, #3
/******************************************************************************
*
* REPORT SALSAS
* ____________________________________________________________________________
* Progam will track salsas and report the total amount of jars sold and
* determine the best and worst selling salsas
*
* Computation:
*
* jars[i] >(<) highest(lowest)
* ____________________________________________________________________________
*
* INPUT
* [SIZE] = Array size
* salsa[SIZE] = Initialization List for salsas
* jars[SIZE] = Allows for inputs to enter subscript
*
* OUTPUT
*
* totalsales = Accumulated inputs total of sales
*
******************************************************************************/
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int SIZE = 5; //Array Size
//Initiialization List of salsa
string salsa[SIZE] = {"Mild", "Medium", "Sweet", "Hot", "Zesty"};
int jars[SIZE]; //Subscript for jars input value
int i; //Counter to cycle to through subscripts
int totalsales = 0; //Accumulator for total sales of jars
//
//Initializing For Loop
for(i = 0; i < SIZE; i++)
{
cout << salsa[i] << " Salsa Jars Sold: ";
cin >> jars[i]; //Input sold jars
while(jars[i] < 0) //Input Validation
{
cout << "Invalid Sales Amount, Please try again." << endl;
cout << salsa[i] << " Salsa Jars Sold: ";
cin >> jars[i];
}
totalsales += jars[i]; //Adds jar input to accumulator
cout << endl;
}
//Initializing For Loop to cycle through subscript
for(i = 0; i < SIZE; i++)
cout << "Jars of " << salsa[i] << " sold: " << jars[i] << "\n";
cout << "Total Sales of Salsas: " << totalsales << endl;
//Creating variables
int highest = jars[0]; //Assigns highest value to subscript [0]
int lowest = jars[0]; //Assigns lowst value to subscript [0]
//
//Initializing For Loop to assign highest and lowest values
for(i = 0; i < SIZE; i++)
{
if(jars[i] > highest) //Determines highest sales
highest = jars[i]; //Assigns highest variable to subscript
if(jars[i] < lowest) //Determines lowest sales
lowest = jars[i]; //Assigns lowest variable to subscript
}
//
//Initializing For Loop
for(i = 0; i < SIZE; i++)
{
if(jars[i] == highest) //When it cycles to the sub that is highest
cout << "Highest Seller: " << salsa[i] << endl;
if(jars[i] == lowest) //When it cycles to the sub that is lowest
cout << "Lowest Seller: " << salsa[i] << endl;
}
return 0;
}