Hi, I'm supposed to create a program that does the following:

A corporation has six divisions, each responsible for sales to different geographic locations. Design a divsales class that keeps the sales data for a division, with the following members:

an array with four elements holding four quarters of sales figures for the division

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

a member function that takes four arguments, each assumed to be the sales for a quarter. The value of the arguments should be added to the static variable that holds the total yearly corporate sales.

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

Write a program that creates an array of Six divSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data is entered, the program should display a table showing the division sales for each quarter. The pgoram should then display the total corporate sales for the year.

I have started working on the code but I can't seem to get the program to ask for 6 division sales ... my program only runs for 1 division and 4 quarters in that division... Also when the total amount is outputed, I get a bunch of garbage like 1N#aGO... etc , instead of a total number calculation.... Can someone show me how to get my code to accept 6 division sales and also how to fix my total amount so it shows the right number? Thank you.

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
    // 2d array with 3 rows and 4 columns for each division and quarter
    float sales [3][4];
    float totalSales = 0;
    int div, qtr;

    for (div = 0; div < 7; div++)
    { for (qtr = 0; qtr < 4; qtr++)
        cout << "Please enter the sales for division " << (div + 1)
            << " Quarter " << (qtr + 1) << ": $";
        cin >> sales[div][qtr];
        cout << sales[div][qtr] << endl;

    cout << endl;

    for (div = 0; div < 7; div++)
    { for (qtr = 0; qtr < 4; qtr++)
    totalSales += sales[div][qtr];

    // Display the total
    cout << "The total sales for the company are: $";
    cout << totalSales << endl;
    return 0;

You're not following your instructions.
Where is your class?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.