Create a program, using at least one For Loop, that displays the Sales Amounts in each of 4 regions during a period of three months. The program should allow the user to enter 4 sets (one set for each region) of three sales amounts (one sales amount for each month). The program should display each regions total sales for the three month period, and the companies total sales (sum of the four regions for three months). Example data below (Remember, the user should be able to enter any data they wish, as long as it follows the below format: Region 1 - 1000, 2000, 3000 Region 2 - 3000, 4000, 6000 Region 3 - 1000, 3000, 2000 Region 4 - 2000, 2000, 4000

Respuesta :

Answer:

C++ code explained below

Explanation:

/*C++ program that prompts sales for four regions of three sales and prints

the sales values to console */

#include<iostream>

#include<iomanip>

#include<cstring>

using namespace std;

int main()

{

  //set constant values

  const int SALES=3;

  const int REGIONS=4;

  //create an array of four regions

  string regionNames[]={"Region 1","Region 2","Region 3","Region 4"};

  //create a 2D array to read sales

  int sales[REGIONS][SALES];

  //read sales for four regions

  for(int region=0;region<REGIONS;region++)

  {

      cout<<regionNames[region]<<endl;

      for(int sale=0;sale<SALES;sale++)

      {

          cout<<"Enter sales ";

          cin>>sales[region][sale];

      }

  }

  //print sales

  for(int region=0;region<REGIONS;region++)

  {

      cout<<regionNames[region]<<"-";

      for(int sale=0;sale<SALES;sale++)

      {

          cout<<setw(5)<<sales[region][sale];

      }

      cout<<endl;

  }

  //pause program output on console

  system("pause");

  return 0;

}

ACCESS MORE