2d Arrays for Sales Divisions and Quarters

Hello All. I am very stuck on my homework assignment and my professor has not responded at all. I know I have mistakes and missing information, but I don't know what those are.

Write a program that calculates information about sales during a year. This program will have an array that will hold the sales totals for 4 divisions
(North, South, East and West, stored in an array as strings for the output) and for 4 quarters. This array will also hold the total for each division and for each quarter.
These totals will be calculated by the program once the values have been inputted by the user. So this array will be a 2-dimensional array with the quarters as the columns and
the divisions as the rows. The last column will hold the totals for the rows (division totals) and the last row will hold the totals for the columns (quarter totals).
The program must use/create the following functions:

int getTotal(int [][COLS]) // gets the total of the complete array except for the totals in the last column and last row.
int getAverage(int [][COLS]) // return the average of all the values in the array except for the column and row with the totals in them.
int getRowTotal(int [][COLS], int) // returns the total for row that is specified by the second parameter to the function.
int getColumnTotal(int [][COLS], int) // returns the total for a column that is specified by the second parameter to the function.
int getHighest(int [][COLS], int&, int&) //returns the highest value in the array. Last two parameters are the index values of where the highest value is located in the 2D array, these can then be used to display which division and quarter.
int getLowest(int [][COLS], int&, int&) //returns the lowest value in the array. Last two parameters are the index values of where the highest value is located in the 2D array; these can then be used to display which division and quarter.

The program should output a table in the same format as below which will then be followed by the division and quarter with the highest value and the division and quarter with the lowest value.

Quarter 1 Quarter 2 Quarter 3 Quarter 4 Division Total
North
South
East
West
Quarter Total

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//Global Constants and Arrays
const int SIZE = 4;
const int ROWS[SIZE], COLS[SIZE];
string qtr[SIZE] = {"Quarter 1", "Quarter 2", "Quarter 3", "Quarter 4"};   //Columns
string div[SIZE] = {"North", "South", "East", "West"};   //Rows
int sales[ROWS][COLS];

//Function prototypes
int getTotal(int[][COLS]); // gets the total of the complete array except for the totals in the last column and last row.
int getAverage(int[][COLS]); // return the average of all the values in the array except for the column and row with the totals in them.
int getRowTotal(int[][COLS], int); // returns the total for row that is specified by the second parameter to the function.
int getColumnTotal(int[][COLS], int); // returns the total for a column that is specified by the second parameter to the function.
int getHighest(int[][COLS], int&, int&); //returns the highest value in the array. Last two parameters are the index values of where the highest value is located in the 2D array, these can then be used to display which division and quarter.
int getLowest(int[][COLS], int&, int&); //returns the lowest value in the array. Last two parameters are the index values of where the highest value is located in the 2D array; these can then be used to display which division and quarter.

int main()
{
		double average, rowTotal[5], columnTotal[4], high, low, sales, salesT;
		
		salesT = getTotal(sales[ROWS][COLS]); // gets the total of the complete array except for the totals in the last column and last row.
		
		average = getAverage(salesT[][COLS]); // return the average of all the values in the array except for the column and row with the totals in them.
		
		rowTotal = getRowTotal([][COLS], ); // returns the total for row that is specified by the second parameter to the function.
		
		columnTotal = getColumnTotal([][COLS], ); // returns the total for a column that is specified by the second parameter to the function.
		
		high = getHighest(high[][COLS], SIZE&, sales&); //returns the highest value in the array. 
		
		low = getLowest(low[][COLS], SIZE&, sales&); //returns the lowest value in the array. 

		//Display the table
		cout << setw(30) << qtr[0] << setw(15) << qtr[1] << setw(15) << qtr[2] << setw(15) << qtr[3] << setw(15) << "Division Total" << endl;
		cout << div[0] <<  setw(25) << sales[0][0] << setw(15) << sales[0][1] << setw(15) << sales[0][2] << setw(15) << sales[0][3] << setw(15) << rowTotal[0] << endl;
		cout << div[1] <<  setw(25) << sales[1][0] << setw(15) << sales[1][1] << setw(15) << sales[1][2] << setw(15) << sales[1][3] << setw(15) << rowTotal[1] << endl;
		cout << div[2] << setw(26) << sales[2][0] << setw(15) << sales[2][1] << setw(15) << sales[2][2] << setw(15) << sales[2][3] << setw(15) << rowTotal[2] << endl;
		cout << div[3] << setw(26) << sales[3][0] << setw(15) << sales[3][1] << setw(15) << sales[3][2] << setw(15) << sales[3][3] << setw(15) << rowTotal[3] << endl;
		cout << "Quarter Total" << setw(17) << columnTotal[0] << setw(15) << columnTotal[1] << setw(15) << columnTotal[2] << setw(15) << columnTotal[3] << setw(15) << rowTotal[4] << endl;
		cout << endl;
		cout << endl;
		cout << "The average sales are: " << fixed << showpoint << setprecision(2) << average << endl;
		cout << "The highest sales are: " << high << endl;
		cout << "The lowest sales are: " << low << endl;


	return 0;
}


int getTotal(int sales [ROWS][COLS])
{
		for (1 = 0; i < SIZE; i++);
		{
			double total = 0;

			for (i = 0; i < SIZE; i++);
			{
				cout << "Please enter the total sales for " << div + 1 << " for " << qtr + 1 << " : $";
				cin >> sales[ROWS][COLS];
			}
		cout << endl;

		total += sales[ROWS][COLS];
		}
	return total;
}


int getAverage(int salesT[][COLS])
{
	return salesT / 16;
}


int getRowTotal(int[][COLS], int)
{
	for (int i = 0; i < SIZE; i++)
	{
		double rowTotal = 0;

		for (i = 0; i < SIZE; i++)
			rowTotal += sales[ROWS][COLS];
	}
	
	return rowTotal;
}

int getColumnTotal(int[][COLS], int)
{
	for (int i = 0; i < SIZE; i++)
	{
		double columnTotal = 0;

		for (i = 0; i < SIZE; i++)
			columnTotal += sales[ROWS][COLS];
	}
	
	return columnTotal;
}

getHighest(int high[][COLS], int SIZE&, int sales&)
{
	int high = sales[0];

	for (int i = 1; i < SIZE; i++)
	{
		if (sales[i] > high)
			high = sales[i];
	}

	return high;
}

getLowest(int low[][COLS], int SIZE&, int sales&)
{
	int low = sales[0];

	for (int i = 1; i < SIZE; i++)
	{
		if (sales[i] < low)
			low = sales[i];
	}

	return low;
}
Topic archived. No new replies allowed.