Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING C++ Question 20 (19 points) (SLO: be able to define and process a two-dime

ID: 3721022 • Letter: U

Question

USING C++

Question 20 (19 points) (SLO: be able to define and process a two-dimensional array: using nested iterations) 15 salesmen have performed sales in 10 different cities and you are asked to process their total sales in those 10 cities as follows: a) (2 pts) Define a two-dimensional array to hold the total sales made by the 15 salesmen in the 10 different cities b) (8 pts) Write a code segment to read each salesman's total sales in all cities into the array. The user will first input the total sales of the first salesman in all the 10 cities, then for the second salesman. etc. c) (9pts) Write a code segment to compute each salesman's sum of total sales in all cities and print it.

Explanation / Answer

#include <iostream>

using namespace std;


int main()
{
int numberOfSalesMan = 5;//need to change from 5 10 15 and 3 to 10
int numberOfCities = 3;
int sales[numberOfSalesMan][numberOfCities];
for(int i=0;i<numberOfSalesMan;i++) {
cout<<"Enter salesman "<<i+1<<" sales in cities "<<numberOfCities<<": "<<endl;
for(int j=0;j<numberOfCities;j++) {
cin >> sales[i][j];
}
}
int sumSales = 0;
for(int i=0;i<numberOfSalesMan;i++) {
sumSales = 0;
cout<<"Enter salesman "<<i+1<<" Total Sales: ";
for(int j=0;j<numberOfCities;j++) {
sumSales +=sales[i][j];
}
cout<<sumSales<<endl;
}
return 0;
}

Output: