Array passing to function

Can anyone please show my how to take the prices in this program and place them in an array and then pass them to the function.
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204


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

const double PRICE_FOR_SM = 9.99;    //Shirt prices
const double PRICE_FOR_MED = 12.99;
const double PRICE_FOR_LG = 14.99;
const double PRICE_FOR_XL = 19.99;

const int SM = 0;
const int MED = 0;
const int LG = 0;
const int XL = 0;

void menu();  // This is my Main display
void SizeMenu(); // This is the size menu
void ShirtCount(int s, int m, int l, int XL);
void Sales(double Sales);
void TotalSales(int c);

void ShirtsSold(int&, int&, int&, int&,int&, double&);

int main()
{
    int Small = 0;
	int Medium = 0;
	int Large = 0;
	int XLarge = 0;

	int TotalShirtsSold = 0;

	double TotalOfSales = 0.0;

	int choice;

	cout << fixed << showpoint << setprecision(2);

    menu();     // DISPLAY 

	cin >> choice;  // SELECT MENU OPTION
	cout << endl;


// WHILE LOOP 
  
while (choice != 9)
	{
		switch (choice)
		{
		case 1: 
			ShirtsSold(Small, Medium, Large, XLarge, TotalShirtsSold, TotalOfSales);
			break;
		case 2:
			Sales(TotalOfSales);
			break;
		case 3:
			TotalSales(TotalShirtsSold);
			break;
		case 4: 
			ShirtCount(Small, Medium, Large, XLarge);
			break;
		case 5:
			ShirtCount(Small, Medium, Large, XLarge);
			TotalSales(TotalShirtsSold);
			Sales(TotalOfSales);
			break;
		default:
			cout << "Invalid choice." << endl;  // control for invalid input
		}

		menu();       
        cin >> choice;
        cout << endl;
	}
	
	return 0;
}


// FUNCTION DEFINITIONS

void menu()  // JUST DISPLAYS THE INFORMATION
{
	
	cout <<"****************************************"<<endl;
	cout <<"1: Enter 1 For Shirt Sizes."<< endl;
	cout <<"2: Enter 2 For current sales amount." << endl;
	cout <<"3: Enter 3 For number of shirts sold." << endl;
	cout <<"4: Enter 4 For total of each size sold." << endl;
	cout <<"5: Enter 5 to print the data." << endl;
	cout <<"9: Enter 9 to exit the program." << endl;
	cout <<"****************************************"<<endl;
	cout << endl;

}

void ShirtCount(int s, int m, int l, int xl)
{
	cout << "Small Shirt count: " << s << endl;
	cout << "Medium Shirt count: " << m << endl;
	cout << "Large Shirt count: " << l << endl;
	cout << "X-Large shirt count: " << xl << endl;
}

void Sales(double Money)
{ 
	cout << "Total Sales Amount: $" << Money << endl;
}

void TotalSales(int c)
{
	cout << "Total amount of Shirts Sold: "<< c << endl;
}

void SizeMenu()
{
	
	cout <<"****************************************"<<endl;
	cout <<"1: Enter 1 For Shirt size small" << endl;
	cout <<"2: Enter 2 For Shirt size Medium " << endl;
	cout <<"3: Enter 3 For Shirt size Large " << endl;
	cout <<"4: Enter 4 for Shirt size X-Large " << endl;
	cout <<"9: Enter 9 to exit." << endl;
	cout <<"****************************************"<<endl;
	cout << endl;
}

//function for calculations
void ShirtsSold(int& SmCount, int &MedCount, int& LgCount, int& XlCount,
				int& TotShirts, double& SalesTotal) 
{
	int Size;
	int numOrdered;

	double TotalPrice = 0;


 SizeMenu();  //DISPLAY SIZE OPTIONS
	cin >> Size;  
	cout << endl; 


// Loop for purchasing Shirts
	
while (Size != 9)
	{
		switch (Size)
	    {
		case 1:
			cout << "Enter the number of shirts: ";
			cin >> numOrdered;
			cout << endl<<endl;

			SmCount = SmCount + numOrdered;
			TotalPrice = TotalPrice + numOrdered * PRICE_FOR_SM;
			TotShirts = TotShirts + numOrdered;
			break;
		case 2:
			cout << "Enter the number of shirts: ";
			cin >> numOrdered;
			cout << endl<<endl;

			MedCount = MedCount + numOrdered;
			TotalPrice = TotalPrice + numOrdered * PRICE_FOR_MED;
			TotShirts = TotShirts + numOrdered;
			break;
		case 3:
			cout << "Enter the number of shirts: ";
			cin >> numOrdered;
			cout << endl<< endl;

			LgCount = LgCount + numOrdered;
			TotalPrice = TotalPrice + numOrdered * PRICE_FOR_LG;
			TotShirts = TotShirts + numOrdered;
			break;
	case 4:
			cout << "Enter the number of shirts: ";
			cin >> numOrdered;
			cout << endl<<endl;

			XlCount = XlCount + numOrdered;
			TotalPrice = TotalPrice + numOrdered * PRICE_FOR_XL;
			TotShirts = TotShirts + numOrdered;
			break;
		default:
			cout << "Invalid choice." << endl;
	    }

	    SizeMenu();
	    cin >> Size;
	    cout << endl; 
    }


	cout << "Please pay $" << TotalPrice << endl<<endl;

	SalesTotal = SalesTotal + TotalPrice; // Accumulator for Total price
}


Topic archived. No new replies allowed.