//Amari Mosley CSC5 Chapter 7, P. 444, #3
//
/**************************************************************
*
* CALCULATE MONTHLY SALSA SALES
* ____________________________________________________________
* This program computes the total sales, highest selling, and lowest selling
* salsas from a selection of 5 salsa flavors.
*
* Computation is based on the formula:
* TotalSales += sales[]
* ___________________________________________________________
* INPUT
* salsa1: Salsa sales inputted by user through looping of array
* salsa2:
* salsa3:
* salsa4:
* salsa5:
*
* OUTPUT
* TotalSales: Total Salsa Sales for the month
* HighestSales: Highest selling Salsa flavor and its number of sales
* LowestSales: Lowest selling Salsa flavor and its number of sales
*
**************************************************************/
#include <iostream>
#include <string>
using namespace std;
int main() {
string SalsaNames[5] = { "mild", "medium", "sweet", "hot", "zesty" };
int sales[5];
int TotalSales = 0;
int HighIndex = 0;
int LowIndex = 0;
cout << "Enter the number of jars sold for each salsa type last month:\n";
for (int count = 0; count < 5; count++) {
do { // Prompts user to enter sale numbers
cout << SalsaNames[count] << ": ";
cin >> sales[count];
if (sales[count] < 0) { // Input Validation
cout << "Error: Jars sold cannot be negative. Please try again.\n";
}
} while (sales[count] < 0); // Input Invalid then run loop again
TotalSales += sales[count];
}
for (int count = 1; count < 5; count++) {
// Calculates Highest and Lowest Sales
if (sales[count] > sales[HighIndex]) {
HighIndex = count;
}
if (sales[count] < sales[LowIndex]) {
LowIndex = count;
}
}
// Output Complete Sales Report
cout << endl;
cout << "\n MONTHLY SALSA SALES REPORT \n";
cout << "Total Sales: " << TotalSales << " jars\n";
cout << "Highest Selling Product: " << SalsaNames[HighIndex] << " (" << sales[HighIndex] << " jars)\n";
cout << "Lowest Selling Product: " << SalsaNames[LowIndex] << " (" << sales[LowIndex] << " jars)\n";
}