Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:11:23+00:00 2026-05-22T12:11:23+00:00

i was creating a seating program and i was wonder if there was a

  • 0

i was creating a seating program and i was wonder if there was a way to count the loops and place it in a variable. im trying to let the user know how many tickets he purchased

#include <iostream>
#include <iomanip>
#include <string>
#include <istream>
#include <fstream>
using namespace std;

const int numberOfRow = 15;
const int numberOfCol = 20;
void print(char matrix[][20],int numberOfRow, int numberOfCol);


int main()
{ 
    ifstream datafile;
    int i, j;
    char matrix[numberOfRow][numberOfCol], seat[numberOfRow][numberOfCol];
    char option;
    int row, col, totalsold;
    float totSold, temp,price = 0 , ticketprice[numberOfRow], totRevenue;
    bool another = true;
    string filename;
    datafile.open("c:\\price.dat"); 

    for(i=0;i<numberOfRow;++i)
    { 
        datafile >> temp;
        ticketprice[i]=temp;
        cout<< "Row ";
        cout<< setw(2)<< fixed << setprecision(2)<< i << setw(7) << ticketprice[i]<< endl;
    }

    for(i = 0; i< numberOfRow; i++)
        for(j = 0; j< numberOfCol; j++)
            matrix[i][j] = '*';

    print(matrix,numberOfRow, numberOfCol);

    while(another)
    {
        totalsold = 0;
        totRevenue = 0; 
        cout << "Please enter the row you would like to sit in: " << endl;
        cin >> row;
        cout << "Please enter the column you would like to sit in: " << endl;
        cin >> col;
        cout << "would you like to purchase more tickets? <y,n>" << endl;
        cin >> option;
        matrix[row][col] = '#';
        /*totRevenue = totRevenue + ticketprice[row];*/


        if(option == 'y' || option == 'Y')
        {
            another = true;
        }

        else 
        {
            another = false;
            print(matrix,numberOfRow, numberOfCol);
            totRevenue = totRevenue + ticketprice[row];
        }
    }

    totRevenue = totRevenue + ticketprice[row];
    cout << "Total Tickets Sold: " << endl;// << totSold << endl;
    cout << "Total Revenue: $ " << fixed << setprecision(2)<< totRevenue<< endl;
    cin >> i;
    cin.get();
    return 0;

}
void print(char matrix[][20],int numberOfRow, int numberOfCol)
{
    int row, col, i, j;

    cout << "seat:   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19"<< endl;
    for(i = 0; i < numberOfRow; i++)
    {
        cout << "row" << setw(3)<< i;
        for(j = 0; numberOfCol > j; j++)
            cout << setw(3) << matrix[i][j];

        cout << endl;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:11:24+00:00Added an answer on May 22, 2026 at 12:11 pm

    Are you sure about your while loop ?

    Something like this, would make more sens:

    //...
    
    int totalsold = 0;
    float totRevenue = 0.0;
    
    while(another)
    {
        cout << "Please enter the row you would like to sit in: " << endl;
        cin >> row;
        cout << "Please enter the column you would like to sit in: " << endl;
        cin >> col;
        cout << "would you like to purchase more tickets? <y,n>" << endl;
        cin >> option;
        matrix[row][col] = '#';
    
        ++totalsold; // increment the number of tickets sold
        totRevenue += ticketprice[row]; // increment to total price of the tickets
    
        if(option == 'n' || option == 'N')
        {
            another = false; // exit the loop
        }
    }
    
    print(matrix,numberOfRow, numberOfCol); 
    cout << "Total Tickets Sold: " << totalsold << endl;
    cout << "Total Revenue: $ " << fixed << setprecision(2)<< totRevenue<< endl;
    
    //...
    

    However, there is plenty of strange things in the provided code. But the most important is to keep practicing, so keep playing with the code and those strange things will disappear like magic with experience 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way of creating a new setting in the Settings.settings file during
I'm thinking of creating a program to let me play or solve slitherlink puzzles,
I am creating a non-deterministic orchestration to handle convoys. I know I am setting
I'm thinking of creating a drawing program with layers, and using GDI+ to display
I'm creating a program to transfer text from a word document to a database.
I've a custom installer program that has worked fine, but it asks the user
I am creating a login menu in C++ i wish to give the user
I'm creating an Asp.Net program UI where users can browse and change information in
Is there any way to allow non-Administrator users to install, upgrade or uninstall an
I have little program creating a maze. It uses lots of collections (the default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.