Program code to copy:
// ---------------------------------------------- chipsSalsa.cpp ---------------------------------------------- //
#include<iostream>
#include<iomanip>
using namespace std;
// --- Two Parallel Arrays -> (One for Salsa
names) & (One for number of jars sold for each Salsa) -->
Making them Global
// --- Initializing salsaNames array
string salsaNames[] = {"mild", "medium", "sweet", "hot",
"zesty"};
int jarsSold[5];
// --- A function to prompt the user to enter number of jars
sold for each type & fills the jars as specified in
statement
void fillJarsSoldArray(){
// --- Using a for loop to enter values
for(int i=0; i<5; i++){
cout<<"\nEnter the number of
jars sold for "<<salsaNames[i]<<": ";
cin>>jarsSold[i];
// --- Then check for negative
value & continue prompting unitl user enters positive
value
// --- Then as getInt() determines
that it cannot go above 1000000, so also implyinng getInt()
condition
while(jarsSold[i] < 0 ||
jarsSold[i] > 1000000){
cout<<"\tInvalid. Enter a number between 0 and 1000000:
";
cin>>jarsSold[i];
}
}
}
// --- A function to print Sales for each Salsa type
void printSales(){
// --- printing according to given format
cout<<"\n\n";
for(int i=0; i<5; i++){
cout<<left<<setw(10)<<salsaNames[i]<<right<<setw(10)<<jarsSold[i]<<endl;
}
}
// --- A function that will calculate & return total sales
int getTotal(){
int totalSales = 0; // --- A variable for
storing total sales
for(int i=0; i<5; i++){
totalSales +=
jarsSold[i]; // --- With each iteration, adding
jars for each salsa
}
return totalSales;
}
// --- A function that determines the indices of highest & lowest selling salsas
void getHighestLowestSelling(int * highest, int *
lowest){
// --- Variables to store highest & lowest assign
0 to highest & assume first index value is minimum
int highestSales = 0, lowestSales = jarsSold[0];
// --- Then further iterating array to get Highest
& lowest sales
for(int i=0; i<5; i++){
if(jarsSold[i] >
highestSales){
highestSales =
jarsSold[i];
*highest =
i;
}
if(jarsSold[i] <
lowestSales){
lowestSales =
jarsSold[i];
*lowest =
i;
}
}
}
int main(){
// --- Filling number of jars sold
(soldarray) by calling function fillJarsSoldArray
fillJarsSoldArray();
// --- display sales for each salsa type by
calling function printSales
printSales();
// --- displaying total sales by calling
functions getTotal
cout<<"\nThe total number of jars sold is
"<<getTotal()<<endl;
// --- Two variables to determine highest
& lowest sales
int highest = 0 , lowest = 0;
// --- Passing these to function
getHighestLowestSelling because as specified we have to return
indices of both
// --- highest & lowest sales, we cannot return
two values, so we will pass these values by
reference
getHighestLowestSelling(&highest,
&lowest);
// --- print highest & lowest selling
type
cout<<"The highest selling type is
"<<salsaNames[highest]<<endl;
cout<<"The lowest selling type is
"<<salsaNames[lowest]<<endl;
}
Sample output:
--------------------------------------------------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERIES........................
HIT A THUMBS UP IF YOU DO LIKE IT!!!
Enter the number of jars sold for mild: -1 Invalid. Enter a number between 0 and 1000000: 1000001 Invalid. Enter a number between 0 and 1000000: 100 Enter the number of jars sold for medium: 500 Enter the number of jars sold for sweet: 0 Enter the number of jars sold for hot: 250 Enter the number of jars sold for zesty: 1000 100 mild medium 500 sweet hot 250 zesty The total number of jars sold is 1850 The highest selling type is zesty The lowest selling type is sweet 1000
Program 2 <100 points>: Chips and Salsa (chipsSalsa.cpp) Write a program that lets a maker of...
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...
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...
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...
The XYZ Company needs you to write a program that will allow them to enter the weekly sales for a salesperson and then the program will calculate things such as most sales (and what day on which they happened), least sales (and day on which they happened), total sales, and daily average. The program will need to do the following: • Validate the user input to ensure that it is not less than 0.0 (0.0 will be acceptable if there...
Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...
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...
2. Write a C++ program, that generates a set of random integers and places them in an array. The number of values generated and their range are entered by the user. The program then continually prompts the user for one of the following character commands: a: display all the values I: display the values less than a given value g display the values greater than a given value e: display all odd values o: display all even values q: quit...
In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...
8.7 LAB*: Program: Online shopping cart (Part 2)Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input.This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).(1) Extend the ItemToPurchase class per the following specifications:Private fieldsstring itemDescription - Initialized in default constructor to "none"Parameterized...
Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...