Page 1 of 1

Assignment – Corporate Sales Data You are asked to write a program that uses an array of structures to store the followi

Posted: Thu Jul 14, 2022 2:13 pm
by answerhappygod
Assignment – Corporate Sales Data
You are asked to write a program that uses an array ofstructures to store the following data of a company -Division name, Q1 Sales, Q2 Sales, Q3 Sales, Q4 Sales, annualdivision sales, and average quarterly division sales.
The program will interactively prompt for Division name, Q1Sales, Q2 Sales, Q3 Sales, Q4 Sales. Each division’s annualdivision sales and average quarterly sales will be calculated andstored in the appropriate members of each structure. Program willalso compute company’s grand total sales for the year.
There are 4 Divisions in the company (East, West, North, South)and NUM_DIVISIONS is defined as a constant thatstores the number of divisions.
The member of the array-company has the following members:
struct companyInfo {
string division_name;
double q1Sales;
double q2Sales;
double q3Sales;
double q4Sales;
double annualSales;
double averageSales;
};
const int NUM_DIVISIONS = 4; // Array size
companyInfo company[NUM_DIVISIONS]; //array declaration
To compute the total sales of each division: annualSales = q1Sales + q2Sales + q3Sales + q4SalesThese variables should be indexed in actual coding
To compute the average quarterly sales of each division: averageSales = (q1Sales + q2Sales + q3Sales +q4Sales) / 4 These variables should be indexed in actualcoding
Sample Data Entry Screen:
Division Name: East
Q1 Sales (in thousands): 100
Q2 Sales (in thousands): 175.5
Q3 Sales (in thousands): 200.25
Q4 Sales (in thousands): 95
Tip: 1. To enter the name of the division, you use getlinefunction. cin will NOT work. To clear the buffer for the next newdata entry use cin.ignore() at the bottom of the body of the forloop used for data entry.
Use the following functions to perform different tasks. (MUSTuse these function calls)
1. This function division name, Q1 sales, Q2 sales, Q3 sales, Q4sales of each division getData (company,NUM_DIVISIONS);
2. This function computes the annual sales and average sales ofeach division compute (company,NUM_DIVISIONS);
3. This function computes the company’s grand total sales forthe year total = grandTotal (company,NUM_DIVISIONS);
4. This function displays the detail lines of each Divisionname, Q1 sales, Q2 sales, Q3 sales, Q4 sales, Annual Sales, AverageSales and the Grand Total Annual Sales of the company.displaySummary (company, total,NUM_DIVISIONS);
Use the following data:
Name Q1 Sale Q2 Sales Q3 Sales Q4 Sales
East 100.00 175.50 200.25 95.00
West 127.30 103.00 75.35 122.00
North 98.15 175.50 147.25 80.00
South 224.50 186.25 155.60 95.32
Sample Output: All names are aligned to the left as shown in thedisplay and all dollar amounts are aligned to the right. All thedollar amounts will be rounded to two digits afterdecimal point.
Sales (inthousands)
Name Q1 Sale Q2 Sales Q3 Sales Q4 Sales Annual sales AverageSales
East 100.00 175.50 200.25 95.00 570.75 142.69
West 127.30 103.00 75.35 122.00 427.65 106.91
North 98.15 175.50 147.25 80.00 500.90 125.22
South 224.50 186.25 155.60 95.32 661.67 165.42
Grand Total Annual Sales 2160.97
Programmer Name: Student Name