ok I have everything good...
except how do I change the highest and lowest values into names
something like:
The highest selling product is mild.
The lowest selling product is hot.
CODE
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
double sum(double array[], int salsa)
{
double total = 0;
for (int count = 0; count < salsa; count++){
total += array[count];
}
return total;
}
double getHightest(double array[], int salsa)
{
double highest;
highest = array[0];
for (int count = 1; count < salsa; count++){
if (array[count] > highest)
highest = array[count];
}
return highest;
}
double getLowest(double array[], int salsa)
{
double lowest;
lowest = array[0];
for (int count = 1; count < salsa; count++)
{
if (array[count] < lowest)
lowest = array[count];
}
return lowest;
}
int main()
{
const int SALSA = 5;
double n_jars[SALSA];
string name[SALSA] = { "mild", "medium", "sweet", "hot", "zesty" };
double total;
double highest;
double lowest;
cout << "Enter the number of jars sold for: " << endl;
for ( int count = 0; count < SALSA; count++ ){
cout << name[count] << ": ";
cin >> n_jars[count];
}
for ( int count = 0; count < SALSA; count++ ){
cout << "The sales for " << name[count] << " is " << n_jars[count] << endl;
}
total = sum(n_jars, SALSA);
highest = getHightest(n_jars, SALSA);
lowest = getLowest(n_jars, SALSA);
cout << "The total amount of sales is " << total << endl;
cout << "The highest selling product is " << highest << endl;
cout << "The lowest selling product is " << lowest << endl;
}