//Charlotte Davies-Kiernan CS1A Chapter 7 P.444 #3
//
/******************************************************************************
*
* Compute Salsa Sales
* ____________________________________________________________________________
* This program will determine the sells for each salsa type: mild, medium,
* sweet, hot and zesty. The prgram will produce a report that displays the
* sales for each salsa type, the total amount of sales of all the salsas,
* and the names of the highest and lowest selling products.
* ____________________________________________________________________________
* Input
* SIZE :The amount of salsa options
* salsaNames :The options of salsas sold
* jarsSold :The amount of jars sold per option
* Output
* totalSales :Total amount of jars sold
* highest :The salsa option that was sold the most
* lowest :The salsa option that was sold the least
*****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
//Data Dictionary
const int SIZE = 5; //INPUT - The amount of salsa options
string salsaNames[SIZE] = {"mild", "medium", "sweet", "hot", "zesty"};
//INPUT - The options of salsas sold
int jarsSold[SIZE]; //INPUT - The amount of jars sold per option
int totalSales = 0; //OUTPUT - Total amount of jars sold
int highest = 0; //OUTPUT - The salsa option that was sold the most
int lowest = 0; //OUTPUT - The salsa option that was sold the least
//User Input
cout << "Enter the number of jars sold for each type of salsa: " << endl;
for(int i = 0; i < SIZE; i++){
do{
cout << salsaNames[i] << ": " << endl;
cin >> jarsSold[i];
//Input Validation
if(jarsSold[i] < 0){
cout << "Error: Sales cannot be negative. Please re-enter." << endl;
}
} while(jarsSold[i] < 0);
}
//Calculations
totalSales = jarsSold[0];
for(int i = 1; i < SIZE; i++){
totalSales += jarsSold[i];
if(jarsSold[i] > jarsSold[highest])
highest = i;
if(jarsSold[i] < jarsSold[lowest])
lowest = i;
}
//Display Results
cout << "SALSA SALES REPORT: " << endl;
for(int i = 0; i < SIZE; i++){
cout << salsaNames[i] << ": " << jarsSold[i] << " jars sold" << endl;
}
cout << "Total sales: " << totalSales << " jars" << endl;
cout << "Highest selling product: " << salsaNames[highest] << " (";
cout << jarsSold[highest] << " jars)" << endl;
cout << "Lowest selling product: " << salsaNames[lowest] << " (";
cout << jarsSold[lowest] << " jars)" << endl;
return 0;
}