Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mandatory Instructions Write a program to read in and process sales data for all of the divisions in a company. This program will give you

Mandatory Instructions Write a program to read in and process sales data for all of the divisions in a company. This program will give you practice with file input and pointers to structs. Input from file For each division in the company, five lines of data are stored in the data file in this order:

Division Name (a string)

Quarter 1 Sales (an integer)

Quarter 2 Sales (an integer)

Quarter 3 Sales (an integer)

Quarter 4 Sales (an integer) The file prog3.txt is stored in the class library. Output Your program should produce output on the screen showing the amounts for each division as well as the summary data shown in the sample output. Program Design Your main function should do the following: 1. Allocate space using a pointer variable for a Corporation structure to store the data for the corporation including the total sales for each quarter and the number of divisions in the corporation.

Total Quarter 1 Sales (an integer )

Total Quarter 2 Sales (an integer)

Total Quarter 3 Sales (an integer)

Total Quarter 4 Sales (an integer)

Number of Divisions (an integer) 2. Allocate space using a pointer variable for a Division structure to store the data for a company division including its name and the four quarterly sales amounts (string and integer). These pointers should be used in all processing with the corporation and division data. 3. Create a while loop to read in the sales data for each division from the prog3.txt file and create a report like the one shown on the next page. Call these three functions each time through the while loop. a. Call a function named getDivision to read in the data for one division. Pass the Division pointer and the input file object to this function. It should read in data for one division and store the data in the Division struct using the pointer variable.

b. Call a function named printDivision to write a line of output to display the division name, four quarterly sales amounts and the total sales for the year for that division. Pass the pointer to the Division structure to this function. c. Call a function named addDivision to add this division's sales amounts to the corporate sales amounts. Pass the pointer of both the Corporation and Division structures to this function. The "Number of Divisions" data member should be incremented each time this function is called. 4. After all data has been read in and processed call a final function named printCorpSummary to print the total corporate sales for each quarter, the total sales for all quarters for the year, the average quarterly sales for each quarter and the highest and lowest quarters for the corporation. Pass the pointer to the Corporation structure to this function. 5. Deallocate the space you allocated for the structures. Sample Output These are only provided to give you general guidance with formatting of the output. VERIFY your figures!!!

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago