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
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const int NUM_SECTIONS = 3,
ROWS_IN_SECTION = 5,
SEATS_IN_ROW = 8;
double seatTable[NUM_SECTIONS][ROWS_IN_SECTION][SEATS_IN_ROW];
// Function prototypes
void fillArray(double seats[NUM_SECTIONS][ROWS_IN_SECTION][SEATS_IN_ROW]);
void showArray(double seats[NUM_SECTIONS][ROWS_IN_SECTION][SEATS_IN_ROW], double price);
int main()
{
double price = 150.00;
double f = price,
s = f - (f * 0.10),
t = s - (s * 0.10),
l = t - (t * 0.15);
double finalPrice;
// Define 3-D array to hold seat prices
double seats[NUM_SECTIONS][ROWS_IN_SECTION][SEATS_IN_ROW] = { { { f, f, f, f, f, f, f, f },
{ f, f, f, f, f, f, f, f },
{ f, f, f, f, f, f, f, f },
{ s, s, s, s, s, s, s, s },
{ s, s, s, s, s, s, s, s } },
{ { t, t, t, t, t, t, t, t },
{ t, t, t, t, t, t, t, t },
{ t, t, t, t, t, t, t, t },
{ t, t, t, t, t, t, t, t },
{ t, t, t, t, t, t, t, t } },
{ { l, l, l, l, l, l, l, l },
{ l, l, l, l, l, l, l, l },
{ l, l, l, l, l, l, l, l },
{ l, l, l, l, l, l, l, l },
{ l, l, l, l, l, l, l, l } } };
showArray(seats, price);
finalPrice = (f * 24) + (s * 16) + (t * 40) + (s * 40);
cout << "\nThe total collected for the SOLD OUT show equals: $" << finalPrice << endl;
return 0;
}
void showArray(double seats[NUM_SECTIONS][ROWS_IN_SECTION][SEATS_IN_ROW], double price)
{
cout << fixed << showpoint << setprecision(2);
for (int section = 0; section < NUM_SECTIONS; section++)
{
double rowTotal = 0.0;
cout << "\n\nSection" << (section + 1);
for (int row = 0; row < ROWS_IN_SECTION; row++)
{
cout << "\nRow " << (row + 1) << ": ";
for (int seat = 0; seat < SEATS_IN_ROW; seat++)
{
cout << setw(7) << seats[section][row][seat];
rowTotal += seats[section][row][seat];
}
cout << " Total =" << rowTotal;
}
}
cout << endl;
}
|