Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that will print a yearly sales report using the data contained in a file. Print page and column headings as shown

Write a C++ program that will print a yearly sales report using the data contained in a file. Print page and column headings as shown on the last page. The data for the report is contained in a text-type file named data8.txt. A copy of this file is located on the network in both the CSCI1301A and CSCI1301B folders. Make a copy for yourself and place it in your own folder. The last line of the data file is just a line of 0s zeros and is not considered part of the data. This line is used to terminate the loop you will use to read from the file.

The records in the file contain sales transaction records for an industrial products company for the current year. Each line of the file represents one sales transaction and contains the following information:

Data Format

Salesman number Integer (1 5)

Product number Integer (1 6)

Sales amount Double

The salesmen and products listed in the data file are identified by numbers as indicated below. This saves disk space, and facilitates processing by the use of subscripts and arrays. Use these numbers as subscripts to add up the totals for each salesman and product as the individual records are processed. Because all of our string data type functions are not available for our use, you will need to use an if or switch statement to print out the names of the salesmen and the names of the products. Sales amounts can be placed in an array of type double.

Salesman Product

1 Alan 1 Angle

2 Bob 2 Brace

3 Charles 3 Corner

4 Donald 4 Doppler

5 Earl 5 Evener

6 Frame

After printing the data in the file, print out the totals by salesman and also by product as shown. Use loops and subscripts to print out the totals from the arrays. This will shorten and should simplify the program. Turn in a printout of your source code and a printout the sales report generated. Your sales report should look EXACTLY like the one I have mapped out for you below:

YOUR NAME SALES REPORT CHAPTER 9 LESSON 2 Salesman Product Amount

2 Bob 6 Frame 5781.26 5 Earl 1 Angle 1662.34 3 Charles 4 Doppler 3221.58 2 Bob 2 Brace 2543.19 1 Alan 3 Corner 2684.27 4 Donald 5 Evener 6135.74 5 Earl 2 Brace 4713.98

Salesman Totals 1 Alan 102422.69 2 Bob 450433.51 3 Charles 368189.24 4 Donald 182563.74 5 Earl 594367.48

Product Totals

1 Angle 483495.33 2 Brace 299628.46 3 Corner 286472.29 4 Doppler 155742.58 5 Evener 416378.73 6 Frame 576287.66

2 4 1087.23 1 1 30478.00 1 2 50211.35 3 3 5087.98 4 5 54387.45 2 4 67549.22 1 1 12988.70 4 2 44187.00 3 4 67511.76 3 3 417.90 1 2 89211.90 4 1 9018.44 1 6 34755.43 3 4 12953.63 1 3 56191.00 4 2 5739.38 4 5 44879.50 2 4 12977.00 3 1 67388.55 1 4 45611.90 4 3 76344.98 2 2 43200.76 2 3 1957.23 1 2 45268.00 1 1 23751.35 3 5 4922.98 4 4 53757.45 2 6 53779.22 1 2 37228.70 4 4 84647.00 3 3 73911.75 3 4 737.90 1 5 36211.90 4 2 9098.44 1 5 55155.43 3 3 83653.63 1 2 46731.00 4 4 2649.38 4 6 63479.50 2 5 42747.00 3 2 38468.55 1 5 83571.90 4 4 44734.98 2 3 83540.76 0 0 0.0 #include #include #include using namespace std; void readData(ifstream& inFile, int& salesmanNum, int& productNum, double& salesAmount); void printData(ifstream& outFile, int salesmanNum, int productNum, double salesAmount); void accumulateProductionTotals (double salesmanTotals[], int productNum, double salesAmount); void printSalesmanTools (double salesmanTotals[]); void printProductTotals (double productTotals[]); int main() { int salesmanNum, productNum; double salesAmount; double salesmanTotals[5]; double productTotals[6]; ifstream inFile; ofstream outFile; inFile.open("dataIn.txt"); outFile.open("dataOut.txt"); outFile<<"YOUR NAME \t CHAPTER 9 LESSON 2"<>salesmanNum>>productNum>>salesAmount; } void printData(ofstream& outFile, int salesmanNum, int productNum, double salesAmount) if(salesmanNum ==1) outFile<<"1 Alan\t"; else if(salesmanNum ==2) outFile<<"2 Bob\t"; else if(salesmanNum ==3) outFile<<"3 Charles\t"; else if(salesmanNum ==4) outFile<<"4 Donald\t"; else if(salesmanNum ==5) outFile<<"5 Earl\t"; if(productionNum ==1) outFile<<"1 Angle \t"; else if(productNum ==2) outFile<<"2 Brace \t"; else if(productNum ==3) outFile<<"3 Corner \t"; else if(productNum ==4) outFile<<"4 Doppler \t"; else if(productNum ==5) outFile<<"5 Evener \t"; else if(productNum ==6) outFile<<"6 Frame \t"; outFile<< 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the various steps in the ter1nination interview?

Answered: 1 week ago