Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING C++ Class Declaration/definition including data members, static members, m

ID: 3695432 • Letter: U

Question

USING C++

Class Declaration/definition including data members, static members, member functions, and class implementation.

Problem Specification:

The XP corporation has four regions, each responsible for sales to a different geographic location. Design a DivSales class that keeps sales data for a division, with the following members:

A data member that holds the region name, possible values are (“East”, “West”, ”North”, “South”).

An array with four elements for holding four quarters of sales figures for the region.

A private static variable for holding the total corporate sales for all divisions for the entire year.

A constructor that initializes the name to null “”, and the quarters to 0;

A null destructor.

A member function that prompts the user to enter the region name and sales for four quarters for that region. The value entered should be added to the static variable that holds the yearly corporate sales.

A member function that returns the region name.

A function that takes an integer argument with the range 0 to 3. The argument is to be used as a subscript into the regions quarterly sales array. The function should return the value of the array element with that subscript.

A member function that returns the total sales for any given region.

A member function that returns the total sale for all regions.

Write a program that creates an array of four DivSales objects. The program should ask the user to enter the region’s name, and sales for four quarters for each region. After the data is entered, the program should display a table showing each region’s name followed by the sales for each quarter, and then followed by the total sale for the region. At the end, the program should display the total corporate sales for the year.

Sample input:

Enter Region : East

Quarter 1 : 32000

Quarter 2 : 34000

Quarter 3 : 45000

Quarter 4 : 55000

Enter Region : West

Quarter 1 : 1000

Quarter 2 : 2000

Quarter 3 : 3000

Quarter 4 : 4000

Enter Region : North

Quarter 1 : 2000

Quarter 2 : 4000

Quarter 3 : 6000

Quarter 4 : 8000

Enter Region : South

Quarter 1 : 3000

Quarter 2 : 6000

Quarter 3 : 9000

Quarter 4 : 12000

Sample output:

East

        Quarter 1 32000.00

        Quarter 2 34000.00

        Quarter 3 45000.00

        Quarter 4 55000.00

Region’s total : 166000.00

West

        Quarter 1 1000.00

        Quarter 2 2000.00

        Quarter 3 3000.00

        Quarter 4 4000.00

Regions total : 10000.00

North

        Quarter 1 2000.00

        Quarter 2 4000.00

        Quarter 3 6000.00

        Quarter 4 8000.00

Regions total : 20000.00

South

        Quarter 1 3000.00

        Quarter 2 6000.00

        Quarter 3 9000.00

        Quarter 4 12000.00

Regions total : 30000.00

All Regions Total : 226000.00

Extra work:

        All Regions Quarter 1 39000.00

        All Regions Quarter 2 46000.00

        All Regions Quarter 3 63000.00

        All Regions Quarter 4 79000.00

Requirements:

Comment thoroughly, each function should have its specification above it (2 or 3 lines).

The client program includes the function main where the array of objects is declared/instantiated.

All accessor member functions are constant.

The class DivSales is defined in a header file.

All methods are defined in an implementation file

Include the preprocessor #ifndef..endif as a guard.

Include a class diagram for the class DivSales.

            main has sufficient comments to explain what is being done.

            every function has specifications.

            A header file contains the class definition.

            A cpp file contains the functions definitions/implementations.

                        The #ifndef guard is properly used where necessary.

            a constructor and destructor are defined and do what they supposed to.

            a static variable accumulates the sales for all regions.

          All accessor member functions are constant.

                        a UML Class diagram is submitted and is correct.

                      an array of objects is declared in main and calls a function to read the data for each of the regions.

            Program runs efficiently, correctly and performs the specified task.

                        Structure of the program (neatness, spacing, indentation, use of variables, organization).

                        output is printed formatted and looks neat.

EXTRA: if at the end, the total of each quarter for the regions is printed by accessing a member function to accumulate the quarters (may require another static variable if you wish)

Explanation / Answer

#include #include using namespace std; class DivSales // Class name { private: //Private function variables static float corpSales; // it has to be static, but when i try it it gives me error float divSales; public: DivSales() {divSales = 0;} //constructor initialization, not sure of this // here it suppose to be an member function with array for the quarterly but i don't understand how to do it. void addDivSales (float s, float s2, float s3, float s4) // Member function passing parameter { divSales += s; corpSales += divSales;} // operations (not quite sure) float getDivisionSales () {return divSales;} // returning values for displaying float getCorpSales () { return corpSales;} }; float DivSales::corpSales=0; //main int main () { DivSales divisions [6]; //class with object array int count; for (count = 0; count < 6; count ++) //loop for prompting user for values { float sal = 0,sal_2 = 0,sal_3 = 0,sal_4 = 0; // variable initialization cout > sal_2 >> sal_3 >> sal_4; divisions[count].addDivSales(sal,sal_2,sal_3,sal_4); //) passing sal to member function addDivsales to do operation } cout