Question

In C++ write a program: Your goal is to ask record the sales for 5 different...

In C++ write a program:

Your goal is to ask record the sales for 5 different types of salsa, the total sales, and the names of the highest and lowest selling products.

Your program should have the following:

 The name of the program should be Assignment7.

 3 comment lines (description of the program, author, and date).

 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. (3 points)

 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. (4 points)

 Produce a table that displays the sales for each type of salsa (2 points), the total sales (2 points), and the names of the highest selling and lowest selling products (4 points).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Editable code:

# include <iostream>
# include<string>

using namespace std;
int main(){
   string salsa[] ={"mild", "medium", "sweet", "hot", "zesty"}; //Initialization of the string array
   int sold[5], total=0,maxi=0, mini=0; //Declaration of variables
   for(int i=0;i<5;i++){ //Taking valid input from user fro each type
       a:
       cout<<"Enter number of jars sold for "<<salsa[i]<<" ";
       cin>>sold[i];
       if(sold[i]<0){ //Validationg the input
           cout<<"Enter a positive value!!";
           goto a;
       }
       if(sold[maxi] < sold[i]){ //Finding maximum sales
           maxi = i;
       }
       if(sold[mini] > sold[i]){ //Finding minimum sales
           mini = i;
       }
       total = total+sold[i]; //Calculating total sales
   }
   //Printing the results
   cout<<"Salsa -------- Sales\n";
   for(int i=0;i<5;i++){
       cout<<salsa[i]<<"\t\t"<<sold[i]<<endl;
   }
   cout<<"\n\nTotal sales: "<<total<<endl;
   cout<<"\n\nHighest selling: "<<salsa[maxi]<<endl;
   cout<<"\n\nLowest selling: "<<salsa[mini]<<endl;
}

Hope this helps
If you have any doubt feel free to comment
Thank You!!

Add a comment
Know the answer?
Add Answer to:
In C++ write a program: Your goal is to ask record the sales for 5 different...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that lets a maker of chips and salsa keep track of their...

    Write a C++ 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...

  • Program 2 <100 points>: Chips and Salsa (chipsSalsa.cpp) Write a program that lets a maker of...

    Program 2 <100 points>: Chips and Salsa (chipsSalsa.cpp) Write a program that lets a maker of chips and salsa keep track of sales for five different types of salsa: mild, medium, sweet, hot, and zesty. The program should use two parallel 5-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...

  • Need to revise the following code to use an array of product objects instead of two...

    Need to revise the following code to use an array of product objects instead of two parallel arrays. The product class will need member variables to hold a product name and a quantity. #include<iostream> #include<string> using namespace std; int main() { //Declare variables const int salsaTypes = 5; const int jarsSold = 5; string salsa[salsaTypes] = { "Mild", "Medium", "Sweet", "Hot", "Zesty" }; int jars[jarsSold]; int totalSales, highestSales, lowestSales; string highestSoldProduct; string lowesetSoldProduct; //Repeat loop for all salsas for (int...

  • In this module, you learned about Arrays in C++ and how to implement arrays within your...

    In this module, you learned about Arrays in C++ and how to implement arrays within your C++ programs. For this assignment, you will implement your knowledge of arrays for Michigan Popcorn Company’s sales management system. Write a program that lets the Michigan Popcorn Company keep track of their sales for seven different types of popcorn they produce: plain, butter, caramel, cheese, chocolate, turtle and zebra. It should use two parallel seven-element arrays: an array of strings that holds the seven...

  • Code in Java using ( NetBeans ) Chapter 7 Assignment (Popular Candy) - 15 points Your...

    Code in Java using ( NetBeans ) Chapter 7 Assignment (Popular Candy) - 15 points Your goal is to record the sales for 4 different types of candy and determine the total sales and the names of the highest and lowest selling candies. . . Create a String array that stores four different types of candy. Pick whatever candy you would like. (3 points) Have the program prompt the user to enter the number of candy boxes sold for each...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Write a C++ console application that allows your user to capture rainfall statistics. Your program should...

    Write a C++ console application that allows your user to capture rainfall statistics. Your program should contain an array of 12 doubles for the rainfall values as well as a parallel array containing the names of the months. Using each of the month names, prompt your user for the total rainfall for that month. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should...

  • C program (File Processing - Writing) The same Bicycle shop that contracted you to write the...

    C program (File Processing - Writing) The same Bicycle shop that contracted you to write the double array problem in HW5 has now decided that they want to keep a log of all employee transactions. Write a program that will allow users to enter in their name (you only need to use first name) and the item that they sold (for example, “James Bicycle”). After each employee types in a sale, your program should record that sale in a file...

  • Write a C++ Program. you were required to first create a function called average. The return...

    Write a C++ Program. you were required to first create a function called average. The return type is double and it takes in two parameters, one of type string the other of type double. In the average function write a for loop that PROMPT THE USER to enter in a grade 5 times, keep a sum of all the different grades then return the average of the grades. (sum / 5) Next write a function of type double called lowest...

  • ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will...

    ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT