Menu

[Solved]Goal Ask Record Sales 5 Different Types Salsa Total Sales Names Highest Lowest Selling Pro Q37217632

“Your goal is to ask record the sales for 5 different types ofsalsa, the total sales, and the names of the highest and lowestselling products. Create a string array that stores five differenttypes of salsas: mild, medium, sweet, hot, and zesty. The salsanames should be stored using an initialization list at the time thename array is created. Have the program prompt the user to enterthe number of salsa jars sold for each type of salsa using anarray. Do not accept negative values for the number of jars sold.Produce a table that displays the sales for each type of salsa, thetotal sales, and the names of the highest selling and lowestselling products.”

I have already written the code for this assignment, butwhenever I execute the code, the total sales is always two morethan it actually is. I tried to find out what was wrong with it andfound out that whenever I enter in the number of sales for Mildsalsa, it adds on two to the number entered, but for the followingsalsas it adds on normally to the total sales. If anyone can helpme find out what’s wrong I would be glad.

// This program records the sales for 5 different types ofsalsa, the total sales, and the names of the highest and lowestselling products.
#include
#include

using namespace std;

int main (){
const int salsaSize = 5;
  
string salsaTypes[salsaSize] = {
“Mild”, “Medium”, “Sweet”, “Hot”, “Zesty”
};
  
int jarSales[salsaSize];
int totalSales;

for(int i = 0; i < salsaSize; i++){
cout << “Enter the amount of sales ” << salsaTypes[i]<< ” jars: “;
cin >> jarSales[i];
  
if(jarSales[i] < 0){
cout << “The number entered is negative. Enter an amountgreater or equal to zero: “;
cin >> jarSales[i];
  
}
totalSales += jarSales[i];
cout << totalSales << endl;
}
  
cout << “Salsa” << “tt” << “Sales” <<endl;
cout << “——————————–” <<endl;
  
int high = jarSales[0];
int low = jarSales[0];
for(int i = 0; i < salsaSize; i++){
cout << salsaTypes[i] << “ttt” << jarSales[i]<< endl;
  
       if(jarSales[i] > high){
           high =jarSales[i];
       } else if (jarSales[i] <low){
           low =jarSales[i];
       }
}
  
cout << “Total Sales: ” << totalSales <<endl;
cout << “The highest selling salsa is “;
for(int i = 0; i < salsaSize; i++){
if(jarSales[i] == high){
cout << salsaTypes[i] << endl;
}
}
  
cout << “The lowest selling salsa is “;
for(int i = 0; i < salsaSize; i++){
if(jarSales[i] == low){
cout << salsaTypes[i] << endl;
}
}
}

Expert Answer


Answer to “Your goal is to ask record the sales for 5 different types of salsa, the total sales, and the names of the highest and … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *