Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i need a help with this c++ assignment Create a string array that stores five di

ID: 3812436 • Letter: I

Question

i need a help with this c++ assignment

Create a string array that stores five different types of salsas: mild, medium, sweet, hot, andzesty. The salsa names should be stored using an initialization list at the time the namearray is created.

Have the program prompt the user to enter the number of salsa jars sold for each type ofsalsa using an array. Do not accept negative values for the number of jars sold.

Produce a table that displays the sales for each type of salsa, the total sales , and the names of the highest selling and lowest selling products .

Explanation / Answer

// C++ code

#include <iostream>
#include <string.h>
#include <iomanip>

using namespace std;

int main ()
{
//Variable declartion
int totalSalsa = 5, size = 7;
char salsaTypes [totalSalsa][size] = {"mild","medium","sweet","hot","zesty"};
int totalJarsSold [totalSalsa];
int numJarsOfSalsa = 0;
int biggest, smallest;
for (int i = 0; i < totalSalsa; i++)
{
cout<< "Enter the number of " <<salsaTypes[i]<<" salsa jars sold in the past month: ";
cin>> totalJarsSold[i];
while (totalJarsSold[i]<0)
{
cout<< "Please enter a positive number: ";
cin>> totalJarsSold[i];
}
  
numJarsOfSalsa += totalJarsSold[i];
}

for (int i = 0; i < totalSalsa; i++)
{
cout<< "Number of " <<salsaTypes[i]<< " salsa jars sold in the past month: "<<totalJarsSold[i]<<endl;
}
cout<<"Total number of jars sold in the past month: "<<numJarsOfSalsa<<endl;

biggest = totalJarsSold[0];
for (int i =0; i < totalSalsa;i++)
{
if (totalJarsSold[i]> biggest)
{
biggest = totalJarsSold[i];
}
}
cout<<" The highest selling product is: "<<biggest<<endl;
smallest = totalJarsSold[0];
for (int i =0; i < totalSalsa;i++)
{
if (totalJarsSold[i] <smallest)
{
smallest = totalJarsSold[i];

}
  
}
cout<<" The lowest selling product is: "<<smallest<<endl;
//system("pause");

return 0;
}

/*
output:

Enter the number of mild salsa jars sold in the past month: 34
Enter the number of medium salsa jars sold in the past month: 55
Enter the number of sweet salsa jars sold in the past month: 33
Enter the number of hot salsa jars sold in the past month: 23
Enter the number of zesty salsa jars sold in the past month: 77
Number of mild salsa jars sold in the past month: 34
Number of medium salsa jars sold in the past month: 55
Number of sweet salsa jars sold in the past month: 33
Number of hot salsa jars sold in the past month: 23
Number of zesty salsa jars sold in the past month: 77
Total number of jars sold in the past month: 222
The highest selling product is: 77
The lowest selling product is: 23

*/