Create an overloaded output operator operator<< as a stand-alone function for your DivSales class. You may not use friend .The output operator should display the sales for each quarter of a single division (single object of the class) with labels. Remember DivSales represents the quarterly sales of one division of a company. Use it in your main program to output the quarterly sales for each division in the company (for each object in the divisions  array). You will need a loop. After all divisions are displayed, display the total corporate sales for the year.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Create an overloaded output operator operator<< as a stand-alone function for your DivSales class. You may not use friend .The output operator should display the sales for each quarter of a single division (single object of the class) with labels. Remember DivSales represents the quarterly sales of one division of a company.
Use it in your main program to output the quarterly sales for each division in the company (for each object in the divisions  array). You will need a loop. After all divisions are displayed, display the total corporate sales for the year.
// number of divisions
// an array of Divsales objects
// initialized with the default constructor
const int NUM_DIV = 6;
DivSales divisions[NUM_DIV];
DivSales set;
divisions[0].setSales (3000.00, 4000.00, 5000.00, 6000.00); // set values for all objects in divisions array
divisions[1].setSales(3500.00, 4500.00, 5500.00, 6500.00);
divisions[2].setSales(1111.00, 2222.20, 3333.30, 4444.00);
divisions[3]. setSales(3050.00, 4050.00, 5050.00, 6050.00);
divisions[4].setSales(3550.00, 4550.00, 5550.00, 6550.00);
divisions[5].setSales(5000.00, 6000.00, 7000.00, 8000.00);
// Output sales by division
cout <« "Output sales by division :" <« endl;
int i = 0;
while(i <6 ) {
cout « "Sales for Division " « i + 1 « endl;
for (int quarter = 0; quarter < 4; quarter++){
cout <« "Quarter" <« quarter +1 <« endl;
cout « divisions[i].getQSales(quarter) <« endl;
>>
i++j
}
// Output total sales
cout <« "Total Corporate Sales:" <« endl;
int totalSales;
for (int i =e; i < 6;i++){
totalsales +- divisions[i].getCorpSales();
}
cout « totalsales <« endl;
!/ Output sales by division with operator<<
// Output total sales
return 0;
}
Transcribed Image Text:// number of divisions // an array of Divsales objects // initialized with the default constructor const int NUM_DIV = 6; DivSales divisions[NUM_DIV]; DivSales set; divisions[0].setSales (3000.00, 4000.00, 5000.00, 6000.00); // set values for all objects in divisions array divisions[1].setSales(3500.00, 4500.00, 5500.00, 6500.00); divisions[2].setSales(1111.00, 2222.20, 3333.30, 4444.00); divisions[3]. setSales(3050.00, 4050.00, 5050.00, 6050.00); divisions[4].setSales(3550.00, 4550.00, 5550.00, 6550.00); divisions[5].setSales(5000.00, 6000.00, 7000.00, 8000.00); // Output sales by division cout <« "Output sales by division :" <« endl; int i = 0; while(i <6 ) { cout « "Sales for Division " « i + 1 « endl; for (int quarter = 0; quarter < 4; quarter++){ cout <« "Quarter" <« quarter +1 <« endl; cout « divisions[i].getQSales(quarter) <« endl; >> i++j } // Output total sales cout <« "Total Corporate Sales:" <« endl; int totalSales; for (int i =e; i < 6;i++){ totalsales +- divisions[i].getCorpSales(); } cout « totalsales <« endl; !/ Output sales by division with operator<< // Output total sales return 0; }
Output sales by division using operator<< :
Sales for Division 1
Quarter 1: $3000.00
Quarter 2: $4000.00
Quarter 3: $5000.00
Quarter 4: $6000.00
Sales for Division 2
Quarter 1: $3500.00
Quarter 2: $4500.00
Quarter 3: $5500.00
Quarter 4: $6500.00
Sales for Division 3
Quarter 1: $1111.00
Quarter 2: $2222.20
Quarter 3: $3333.30
Quarter 4: $4444.00
Sales for Division 4
Quarter 1: $3050.00
Quarter 2: $4050.00
Quarter 3: $5050.00
Quarter 4: $6050.00
Sales for Division 5
Quarter 1: $3550.00
Quarter 2: $4550.00
Quarter 3: $5550.00
Quarter 4: $6550.00
Sales for Division 6
Quarter 1: $5000.00
Quarter 2: $6000.00
Quarter 3: $7000.00
Quarter 4: $8000.00
Total Corporate Sales: $113510.50
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
Transcribed Image Text:Output sales by division using operator<< : Sales for Division 1 Quarter 1: $3000.00 Quarter 2: $4000.00 Quarter 3: $5000.00 Quarter 4: $6000.00 Sales for Division 2 Quarter 1: $3500.00 Quarter 2: $4500.00 Quarter 3: $5500.00 Quarter 4: $6500.00 Sales for Division 3 Quarter 1: $1111.00 Quarter 2: $2222.20 Quarter 3: $3333.30 Quarter 4: $4444.00 Sales for Division 4 Quarter 1: $3050.00 Quarter 2: $4050.00 Quarter 3: $5050.00 Quarter 4: $6050.00 Sales for Division 5 Quarter 1: $3550.00 Quarter 2: $4550.00 Quarter 3: $5550.00 Quarter 4: $6550.00 Sales for Division 6 Quarter 1: $5000.00 Quarter 2: $6000.00 Quarter 3: $7000.00 Quarter 4: $8000.00 Total Corporate Sales: $113510.50 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY