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

How can i fix this so the output is correct #include <iostream> #include<iomanip

ID: 3816821 • Letter: H

Question


How can i fix this so the output is correct

#include <iostream>
#include<iomanip>
using namespace std;

const int SALSA_TYPE = 5;
const int JARS_SOLD = 5;
void fillJarsSoldArray(const int ar[SALSA_TYPE][JARS_SOLD]) ;
void printSales(const int ar[SALSA_TYPE][JARS_SOLD]) ;
int getTotal(int ar[SALSA_TYPE][JARS_SOLD]) ;
int getHighestLowestSelling(int ar[SALSA_TYPE][JARS_SOLD]) ;

int main()
{
string ar[SALSA_TYPE] = { "mild ", "medium " , "sweet " , "hot " , "zesty" };
int totalSales = 0;
int highestSelling ;
int lowestSelling ;

fillJarsSoldArray(SALSA_TYPE);
printSales(SALSA_TYPE);

cout << left << setw(10) << "The total number of jars sold is " << getTotal(salsa) << endl ;
cout << left << setw(10) << "The highest selling type is " << SALSA_TYPE[highestLowest] << endl ;
cout << left << setw(10) << "The lowest selling type is " << SALSA_TYPE[highestLowest] << endl ;

return 0;
}
void fillJarsSoldArray(const int ar[SALSA_TYPE][JARS_SOLD])
{
for(int i = 0; i < SALSA_TYPE; i++ )
cout << "Enter the number of jars sold for " << salsa[i] << ":" << endl ;
cin >> JARS_SOLD[i] ;

while(JARS_SOLD[i] < 0 ) // check if number is negative
{
cout << "Enter number for jars sold for " << salsa[i] << ": " << endl ;
cin >> JARS_SOLD[i] ;
}
}
void printSales (const int ar[][]) // sales of each salsa type
{
for(int i = 0; i < 5; i++ )
cout << SALSA_TYPE[i] << endl << JARS_SOLD[i] << endl;
}
int getTotal (int salsaTypes[], int jarsSold[])
{
int totalSales ;
for(int i = 0; i < salsaTypes; i++ )
{
totalSales += jarsSold[i] ;
}
cout << endl << " The total number of jars sold is " << totalSales << endl ;
}

int getHighestLowesrSelling(int ar[][])
{
int low = 0;
int high = 0;
for(int i = 1; i < 5; i++)
{
if (ar[low] > ar[i])
{
high = i ;

}
}

}

Program 2

Explanation / Answer

#include <iostream>
#include<iomanip>
using namespace std;
const int SALSA_TYPE = 5;
const int JARS_SOLD = 5;
void fillJarsSoldArray(const int ar[SALSA_TYPE][JARS_SOLD]) ;
void printSales(const int ar[SALSA_TYPE][JARS_SOLD]) ;
int getTotal(int ar[SALSA_TYPE][JARS_SOLD]) ;
int getHighestLowestSelling(int ar[SALSA_TYPE][JARS_SOLD]) ;
int main()
{
string ar[SALSA_TYPE] = { "mild ", "medium " , "sweet " , "hot " , "zesty" };
int totalSales = 0;
int highestSelling ;
int lowestSelling ;
fillJarsSoldArray(SALSA_TYPE);
printSales(SALSA_TYPE);
cout << left << setw(10) << "The total number of jars sold is " << getTotal(salsa) << endl ;
cout << left << setw(10) << "The highest selling type is " << SALSA_TYPE[highestLowest] << endl ;
cout << left << setw(10) << "The lowest selling type is " << SALSA_TYPE[highestLowest] << endl ;
return 0;
}
void fillJarsSoldArray(const int ar[SALSA_TYPE][JARS_SOLD])
{
for(int i = 0; i < SALSA_TYPE; i++ )
cout << "Enter the number of jars sold for " << salsa[i] << ":" << endl ;
cin >> JARS_SOLD[i] ;
while(JARS_SOLD[i] < 0 ) // check if number is negative
{
cout << "Enter number for jars sold for " << salsa[i] << ": " << endl ;
cin >> JARS_SOLD[i] ;
}
}
void printSales (const int ar[][]) // sales of each salsa type
{
for(int i = 0; i < 5; i++ )
cout << SALSA_TYPE[i] << endl << JARS_SOLD[i] << endl;
}

int getHighestLowesrSelling(int ar[][])
{
int low = 0;
int high = 0;
for(int i = 1; i < 5; i++)
{
if (ar[low] > ar[i])
{
high = i ;
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote