How to Develop Sales Summary Formatter in C++?

output, c++, sales information

Programming Challenge: Sales Summary

Use a two-dimensional array to solve the following problem. A company has hour salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Slip contains the following information:

a) The salesperson number
b) The product number
c) The total dollar value of that product sold that day

Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that the information from all the slips for last month is available. Write a program that will read all this information for last month’s sales and summarize the total sales per salesperson by product. All totals should be stored in the two-dimensional array sales. After processing all the information for last month, print the results in tabular format with each of the columns representing a particular salesperson and each of the rows representing a particular product. Cross total each row to get the total sales of each product for the last month; cross total each column to get the total sales by salesperson for last month. Your tabular printout should include cross total to the right of the totaled rows and to the bottom of the totaled column. You should also print the salesperson and the product that sold the most during the last month.

Solution:

main.cpp

#include “main.h”

 
int main ()
{
          salesEmplyee();
          cout << “\n\t above is table as required ENTER 1-9 to exit  “;    
          int STAY;
          cin>>STAY;
return 0;
}
         
void Header (void)
{
   
     cout << “–<summary file have all records information of sales for assignment>-\n”
         
          << endl;
    
}

void settingGUI(){
    
               cout   << “Sales |\t<———————- Summary of products ———–“
                  << “———->\n”
                  << “Person|\n”
                  << “___________________________________________________”
                  << “__________________________\n”
          << setw( 10 ) << 1 << setw( 13 ) << 2
          << setw( 13 ) << 3 << setw( 13 ) << 4
          << setw( 13 ) << 5 << setw( 16 ) << “Total Sales\n”
                  << “_____________________________________________________”
                  << “__________________________\n\n”
          << setiosflags( ios::fixed | ios::showpoint );
     
     }
 
void errorCase(){
       cerr << “File could not be opened\n”;
                exit( 1 );
     
     }

void salesEmplyee(){
     ifstream inputSummaryFile (“summary.txt”, ios::in );
      Header ();
          {
        if ( !inputSummaryFile ) {
              errorCase();
        }
   cout << “\t  ———reading input summary file data——————–“<<endl<<endl;
       
   inputSummaryFile >> salesPerson;
   while ( salesPerson != -1 ) {
   inputSummaryFile  >> product;
   inputSummaryFile >> value;
              sales[ salesPerson ][ product ] += value;
   inputSummaryFile >> salesPerson;
   }
 
     settingGUI();
         
   for ( int i = 1; i < EMP; ++i ) {
      totalSales = 0.0;
      cout << i;
      for ( int j = 1; j < PRODUCTS; ++j ) {
         totalSales += sales[ i ][ j ];
         cout << setw( 13 ) << setprecision( 2 )
              << sales[ i ][ j ];   
         productSales[ j ] += sales[ i ][ j ];
      }
                   
      cout << setw( 13 ) << setprecision( 2 )  
           << totalSales << ‘\n’;
   }
   cout << “\n______________________________________”
        << “________________________________________________\n”
        << setw( 80 ) << ” Grand Total\n”
        << setw( 80 ) << “———–\n”;
   cout << “Total ” << setw( 6 ) << setprecision( 2 )
        << productSales[ 1 ];
       
   for ( int j = 2; j < PRODUCTS; ++j )
      cout << setw( 13 ) << setprecision( 2 )
           << productSales[ j ];
                for ( int j = 0; j < PRODUCTS; ++j)
            grandTotal += productSales[j];
                 cout << setw( 13 ) << grandTotal
                          << “\n” << endl;
                   
}

     
     }

Output Screen:

output, c++, sales information

LEAVE A REPLY

Please enter your comment!
Please enter your name here