38.9k views
3 votes
Write a program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mild, medium, sweet, hot, and zesty. It should use two parallel five-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using an initialization list at the time the name array is created. The program should prompt the user to enter the number of jars sold for each type. Once this sales data has been entered, the program should produce a report that displays sales for each salsa type, total sales, and the names of the highest selling and lowest selling products.

User Cedrick
by
7.3k points

1 Answer

3 votes

Answer:

Using C++ to solve the problem as given below

Step-by-step explanation:

#include<iostream>

#include<string.h>

using namespace std;

int main()

{

string salsa_name[5]={"mild","medium","sweet","hot","zesty"};

int jar_sale[5]={0,0,0,0,0};

int i;

int total=0;

int high=0;

int high_index=0;

int low=0;

int low_index=0;

int temp=0;

for(i=0;i<5;i++)

{

while(temp<=0)

{

cout<<"enter the number of jars sold for "<<salsa_name[i]<<" ";

cin>>temp;

if(temp<=0)

cout<<"invalid data. please try again\\";

}

jar_sale[i]=temp;

temp=0;

}

cout<<"name\t jars sold\\";

cout<<"\\---------------------------\\";

for(i=0;i<5;i++)

{

cout<<" "<<salsa_name[i]<<"\t\t"<<jar_sale[i]<<"\\";

}

low=jar_sale[0];

for(i=0;i<5;i++)

{

total=total+jar_sale[i];

if(jar_sale[i] >= high)

{

high_index=i;

high=jar_sale[i];

}

if(jar_sale[i]<=low)

{

low_index=i;

low=jar_sale[i];

}

}

cout<<"\\ total sale : "<<total;

cout<<"\\ high seller : "<<salsa_name[high_index];

cout<<"\\ low seller : "<<salsa_name[low_index];

}

User Dhasenan
by
7.1k points