Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This Theater seating program is almost complete, but there is an issue with outp

ID: 3660798 • Letter: T

Question

This Theater seating program is almost complete, but there is an issue with outputting Final Sales. The Final total being outputted for Case 1 and the Total sales for Case 2 are outputting in scientific notation (e.g. $2.8e+002) instead a dollar amount, even with Showpoint and Setprecision added.

I'm sure the answer is simple, but after studying for Finals for four other classes, my brain is completely fried.

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

void displayChart();
void rowHiglightChart();

const int SIZE = 15, ROWS = 15, COLS = 30;
char seats[ROWS][COLS], again;
double dollarSales = 0, prices[SIZE];
int numSeats, sR, sC, seatsLeft = 450, ticketSales = 0, rowSales[SIZE], row, runs, runs2;
double total;

int main()
{
for (int c = 0; c < COLS; c++)
{
for (int r = 0; r < ROWS; r++)
seats[r][c] = '#';
}

for (int i = 0; i < SIZE; i++)
{
rowSales[i] = 30;
}

for (int i = 0; i < ROWS;i++)
{
cout<<"Price for row "<<i + 1<<"? ";
cin>>prices[i];
system("CLS");
}

do{

cout<<"Theater Seating: ";
cout<<""1" to buy seats. ";
cout<<""2" to display grand totals. ";
cout<<""3" to view empty seats in a particular row. ";
cout<<""e" to exit. ";

cin>>again;

switch (again)
{
case '1': system("CLS");
displayChart();
cout<<seatsLeft<<", seats left. How many would you like to buy? ";
cin>>numSeats;

if (numSeats < seatsLeft)
{
ticketSales += numSeats;
seatsLeft -= numSeats;
}

displayChart();

for (int i = 0; i < numSeats; i++)
{
total = 0;
if (i > 0)
cout<<"Total so far is $"<<total<<endl;

cout<<"Row of seat you would like to buy? ";
cin>>sR;
cout<<"Column of seat you would like to buy? ";
cin>>sC;

if (seats[sR - 1][sC - 1] == '#')
{
seats[sR - 1][sC - 1] = '*';
dollarSales += prices[sR - 1];
rowSales[sR - 1] -= 1;
total += prices[sR - 1];
displayChart();
system("CLS");
displayChart();
}

else
{
system("CLS");
displayChart();
cout<<"Seat, ("<<sR<<", "<<sC<<"), already taken, try a different one. ";
i -= 1;
continue;
}

}
cout<<"Final total for those seats is $"<<setprecision(2)<<showpoint<<total<<endl;
break;

case '2': system("CLS");
cout<<ticketSales<<" tickets were sold. Sales totaled $"<<setprecision(2)<<showpoint<<dollarSales<<endl;
break;

case '3': system("CLS");
cout<<"Which row would you like to see the available seats in? ";
cin>>row;
system("CLS");
runs = 0;
runs2 = 0;
rowHiglightChart();
cout<<"There are "<<rowSales[row - 1]<<" seats left in row "<<row<<"."<<endl;
break;

case 'E': again = 'e';
break;
case 'e': again = 'e';
break;
default: again = 'e';
break;
}
}while (again != 'e' && again != 'E');

return 0;
}

void displayChart()
{
cout<<"Theater Seating ";
cout<<"'*' = Taken '#' = Available "<<" ";
for (int i = 0; i < 3; i++)
{
for (int i = 1; i<=9; i++)
cout<<i;
cout<<"0";
}

cout<<endl;

for (int r = 0; r < ROWS; r++)
{
cout<<"Row "<<setw(2)<<r + 1<<" ";

for (int c = 0; c < COLS; c++)
cout<<seats[r][c];
cout<<endl;
}
cout<<endl;
}

void rowHiglightChart()
{
cout<<"'*' = Taken '#' = Available "<<" ";
for (int i = 0; i < 3; i++)
{
for (int i = 1; i<=9; i++)
cout<<i;
cout<<"0";
}

cout<<endl;

for (int r = 0; r < ROWS; r++)
{
if ((r == (row - 1)) && (runs < 1))
{
cout<<" ";
for (int i = 0; i < 30; i++)
cout<<"-";
cout<<endl;
r -= 1;
runs += 1;
continue;
}

else if ((r == row) && (runs2 < 1))
{
cout<<" ";
for (int i = 0; i < 30; i++)
cout<<"-";
cout<<endl;
r -= 1;
runs2 += 1;
continue;
}

cout<<"Row "<<setw(2)<<r + 1<<" ";

for (int c = 0; c < COLS; c++)
cout<<seats[r][c];
cout<<endl;
}
cout<<endl;
}

Explanation / Answer

try to use #include or #include as headers
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote