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

Suppose you have a two-dimensional array of double to hold the sales amounts for

ID: 3555234 • Letter: S

Question

  1. Suppose you have a two-dimensional array of double to hold the sales amounts for all your salespeople three years. Assume you employ 50 salespeople and this array already holds valid data.
  1. Write the code to declare the array.
  2. Write the code to count how many of these salespeople had sales over $8000 for the second year.
  3. Write the code to find the highest sales amount over all three years.
  4. Write the code to find the total sales amount for the first year.
  5. Write the function definition, print, that will print the contents of the array. The array will be passed as a parameter.

Explanation / Answer

#include<iostream>
using namespace std;

// Suppose you have a two-dimensional array of double to hold the sales amounts for all your salespeople three years.
// Assume you employ 50 salespeople and this array already holds valid data.

//Write the code to declare the array.
double sales[50][3];

//Write the code to count how many of these salespeople had sales over $8000 for the second year.
int count = 0;
for(int i=0; i<50; i++)
{
if(sales[i][1] > 8000)
count++;
}
cout <<"Number of salespeople had sales over $8000 are " << count << endl;

//Write the code to find the highest sales amount over all three years.
double max = sales[0][0];
for(int i=0; i<50; i++)
{
for(int j=0; j<3; j++)
{
if(sales[i][j] > max) max = sales[i][j];
}
}
cout <<"Highest sales amount over all three years is " << max << endl;

//Write the code to find the total sales amount for the first year.

double first_sum = 0;
for(int i=0; i<50; i++)
first_sum = first_sum + sales[0][0];
cout <<" total sales amount for the first year is " << fisrt_sum << endl;

//Write the function definition, print, that will print the contents of the array. The array will be passed as a parameter.
void print(double sales[50][3])
{
for(int i=0; i<50; i++)
{
for(int j=0; j<3; j++)
{
cout <<sales[i][j]<< " ";
}
cout << endl;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote