Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chips and Salsa C++ help. Ch 7 of C++ from Control structures throyugh Objects. Produce a table that displays the sales for each type of

Chips and Salsa C++ help.

Ch 7 of C++ from Control structures throyugh Objects.

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.

I can do the first two, but how do I make the program output the names of the highest and lowest selling product instead of the numbers.

Here is my code

// Assignment 7

#include #include #include using namespace std;

int main() { const int type = 5; const int string = 7; char salsa[type][string] = { "mild", "medium", "sweet", "hot", "zesty" }; int num[type]; int total = 0; int highest; int lowest; for (int count = 0; count < type; count++) { cout << "Enter the number of " << salsa[count] << " salsa jars sold: "; cin >> num[count]; while (num[count]<0) { cout << "Enter a positive number: "; cin >> num[count]; }

total += num[count]; }

// Display the table headings. cout << " Salsa\t\tSold "; cout << " "; cout << "---------------------------------- "; for (int count = 0; count < type; count++) { cout << salsa[count] << " \t\t " << num[count] << endl; } cout << "Total: " << " \t\t" << total << endl;

highest = num[0]; for (int count = 0; count < type; count++) { if (num[count]> highest) { highest = num[count]; } } cout << "The highest selling product is: " << highest << endl; lowest = num[0]; for (int count = 0; count < type; count++) { if (num[count]

}

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

Here is the full question if that helps

Create a string array that stores five different types of salsas: mild, medium, sweet, hot, and zesty. The salsa names should be stored using an initialization list at the time the name array is created. Have the program prompt the user to enter the number of salsa jars sold for each type of salsa 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

1. Who will you assemble on the team?

Answered: 1 week ago

Question

4. Who would lead the group?

Answered: 1 week ago