9.2 Bookworm bookstores announced a competition running over four weeks for thei
ID: 3908798 • Letter: 9
Question
9.2
Bookworm bookstores announced a competition running over four weeks for their three The branch with the highest sales per week will receive a surprise for that week programmer are requested to wnte a program to keep record of the number of books in each of the three branches over this period of four weeks The (incomplete) program belo the respective number of books sold and stores it in a two-dimensional array called sal rows and three columns The program then displays for each week, the highest num You as a week w inputs ber of book sold Here is an example of the input data for the program Bookworm Bookworm Bookworm South 100 96 110 106 West North Week J1 Week 2 Week 3 Week 4 120 122 101 119 102 And the corresponding output The highest sales in week 1 were 120 books. The highest sales in week 2 were 122 books. The highest sales in week 3 were 119 books. The highest sales in week 4 were 106 books Use the declarations in the (incomplete) program below and do the following 91 Declare the two- dimensional array salea 92 Assume array sales have been initialised Write a program fragment to determine and display the highest sales per week. Daka tf IncludeExplanation / Answer
#include <iostream>
using namespace std;
const int NUM_WEEKS=4;
const int NAME =3;
int main() {
// your code goes here
int highest;
int sales[NUM_WEEKS][NAME];
for(int i=0;i<NUM_WEEKS;i++)
{ highest =sales[i][0];
for(int j=1;j<NAME;j++)
{
if(sales[i][j]>highest)
{
highest= sales[i][j];
}
}
cout<<"The highest sales in week" + (i+1) <<" were"<< highest<<" ";
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.