Answer to Question #5832 in C++ for haruna

Question #5832
write a program that lets a maker of chips and salsa keep track of their sales for 5 different types of salsa they produce: mild, medium, sweet, hot, and zesty. it should use two parallel 5 - element arrays: an array of strings that holds the 5 salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. the salsa name should be stored using an intialization list at the time the 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 product.
1
Expert's answer
2012-01-05T11:31:15-0500
C++:
write a program that lets a maker of chips and salsa keep track of their sales for 5 different types of salsa they produce: mild, medium, sweet, hot, and zesty. it should use two parallel 5 - element arrays: an array of strings that holds the 5 salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. the salsa name should be stored using an intialization list at the time the 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 product.

#include <iostream>
#include <string>
#include <conio.h>
using namespace std;

string names[5];
int sales[5];
int i, HiSell=0, HiName, LowSell=0, LowName;

void main(){

names[0] = "mild";
names[1] = "medium";
names[2] = "sweet";
names[3] = "hot";
names[4] = "zesty";
int total=0;
for (i=0;i<=4;i++){
cout<<"Enter number of sold "<<names[i]<<" jars: ";
cin>>sales[i];
total = total + sales[i];
if (i==0) { HiSell = sales[i]; HiName = i; LowSell=sales[i]; LowName = i; }
if (HiSell<sales[i]) { HiSell=sales[i]; HiName = i; }
if (LowSell>sales[i]) { LowSell=sales[i]; LowName = i; }
}

cout<<"There were sold:\r\n";
for (i=0;i<=4;i++){
cout<<sales[i]<<" "<<names[i]<<" jars"<<"\r\n";
}

cout<<"Total sales: "<<total<<" jars\r\n";
cout<<"Highest sales: "<<HiSell<<" ("<<names[HiName]<<" salsa)\r\n";
cout<<"Lowest sales: "<<LowSell<<" ("<<names[LowName]<<" salsa)\r\n";

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS