Write a program that keeps track the Salsa sales at a local food store. The prog
ID: 3768638 • Letter: W
Question
Write a program that keeps track the Salsa sales at a local food store. The program should output each salsa name, the number of jars sold, and the percentage of the total jars sold by each name. Your program should also output the salsa name with the highest sales. Below is the sample output.
Name Jars Sold % of Total Jars
Mild 100 40.00
Medium 80 32.00
Hot 40 16.00
Zesty 30 12.00
Total 250
Mild has the highest sale: 100 jars
To solve this problem, you will use two dynamic arrays to keep track the salsa names and jars sold. You will ask user for number of salsa names, then create two parallel dynamic arrays, name and jarsSold to keep track the sales for each salsa flavor. The program will allow user to enter the name of each flavor, and the number of jars sold. The program should then output the summary of the sales result (see sample output above
Explanation / Answer
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
//using namespace std;
int main()
{
char Salsa[5][15]= {"mild","medium","sweet","hot","zesty"};
int Sold[5],sum=0,hSold,lSold;
char highest, lowest;
//get data
for(int i=0;i<=4;i++)
{
cout<<" Enter the number of jars sold during the past month for "<<Salsa[i]<<" ";
cin>>Sold[i];
while(Sold[i]<0)
{
cout<<" Not accept negative number. Please reenter: ";
cin>>Sold[i];
}
sum+=Sold[i];
}
hSold=numberOfSold[0];
highest=Salsa[0][0];
for(int x=1;x<4;x++)
{
if(hSold<Sold[x])
{
hSold=Sold[x];
highest=Salsa[x][x];
}
}
lSold=Sold[0];
lowest=Salsa[0][0];
for(int y=1;y<4;y++)
{
if(lSold>Sold[y])
{
lSold=Sold[y];
lowest=Salsa[y][y];
}
}
for(int z=0;z<5;z++)
{
cout<<" The sales for "<<Salsa[z]<<" is "<<Sold[z];
}
cout<<" The total sales is "<<sum;
cout<<" The best product is "<<highest;
cout<<" The worst product is "<<lowest<<endl;
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.