I need help with input collection.

I almost have this complete but I am not sure how to change my input collection. Directions are to: You have to change your input collection to get 4 values (quarterly sales) before calling that one function that stores them in the array.

Any help is appreciated, Thanks!!

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
#include <iomanip>
#include <cmath>
#include <iostream>
using namespace std;

class DivSales      // Class name
{
private:            // Private members
	static float corpSales;       
	float divSales[4]; //stores quarterly sales per division

public:
 // Constructor initialization
	DivSales() 
	{
		divSales[4] = {0.0,0.0,0.0,0.0};
	}

	// Member function passing parameter                            
	void addDivSales (float s1, float s2, float s3, float s4)          
	{	// Equation operations
		divSales[0] = s1;
		divSales[1] = s2;
		divSales[2] = s3;
		divSales[3] = s4;
		corpSales += s1 + s2 + s3 + s4;
	}       
	// Return quarterly values to display
	float getDivisionSales (int qtr) 
	{
		return divSales[qtr];
	}  
	// Return corporate values to display
	static float getCorpSales () 
	{
		return corpSales;
	}     
};

//initializing static data member
float DivSales::corpSales = 0.0;


// Main

int main ()
{
	DivSales divisions [6];     // Object array class

	int count;

	for (count = 0; count < 6; count ++)     //loop for prompting user for values

	{

		float sales = 0;  // Initialize variables
		cout << "Enter the sales for each division ";     // Get user inputs 
		cout << (count + 1) << " : ";       // Display loop divisions

		while (sales < 1)                      // Validates that inputs are greater than 1
		{
			cin >> sales;
			divisions[count].addDivSales(sales);      // Passes sale to addDivsales to complete the operation

			if (sales < 1)
				cout << "Enter a positive number: \n";    // Validates that inputs are greater than 1
		}
	}
	cout << setprecision(2);
	cout << showpoint << fixed;
	cout << "\nHere are the division sales: \n";

	for (count = 0; count < 6; count++)      // Loops to display user inputs on sales
	{
		cout << "Division " << (count + 1) << " $ ";
		cout << divisions[count].getDivisionSales() << endl;   
                                                      
	}
	cout << "Total corporate sales:\t$ ";             
	cout << divisions[0].getCorpSales() << endl;        // Displays total corporate sales 

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