Help with 'seat arrangement' code

There's this complicated code that I have very little idea on how to get it done properly. Take a look at the code first:

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
// movie.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int main()
{
	int seat[5][6], row;

	cout << "Welcome to the movie theater!  Choose a seat.\n";
for( int i=0; i <= 4; i++)
{
		for( int j=0; j <= 5; j++)
		{
			seat[i][j] == j+1;
			
			cout << j+1;
		}
		cout << endl;
}

cout << "Sales amount: " << '0' << endl;
cout << "Sales Volume: " << '0' << endl;


	system("pause");
	return 0;


}

So the code above should display a number grid/char/graph or something like that with the sales thing at the bottom. This program is supposed to ask the user for which seat on which row would one like to have, and after choosing it, the sales amount will change depending on the price and the volume will show how many seats are taken, and then the graph will reappear again, this time with an X over the number (the seat) that is taken. This process will continue until all the seats are taken.

Can I please inquire some advice and help? I hope you understand...

Um, a little help here? I'll make it clearer again:

Movie Ticket Reservation System: Write program to assign seats for one movie program (capacity: 5 rows x 6 seats)
There are two classes of seat: HONEYMOON, NORMAL
HONEYMOON class: row A to B (140 baht each)
NORMAL class: row C to E (120 baht each)
Show the seat arrangement on the screen before assignment.
Show the sales amount (baht) and sales volume (seats).
Do not assign a seat that has already been assigned.

Hint: Use two-dimensional array like "int a[5][6]" to store the data.

SAMPLE INTERFACE
Movie Ticket Reservation System (One Movie Program)

Row E 1 2 3 4 5 6 Sales Amount: 640 BAHT
Row D 1 2 3 4 5 6 Sales Volume: 5 SEATS
Row C 1 X X X 5 6
Row B 1 2 3 4 5 6
Row A 1 X X 4 5 6

Select Row [A..E] :
I believe something like this will work.

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
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int seat[5][6] = {{1,2,3,4,5},
                      {1,2,3,4,5},
                      {1,2,3,4,5},
                      {1,2,3,4,5},
                      {1,2,3,4,5},
                      {1,2,3,4,5}};
                      
    int seatsSold = 0;

    cout << "Welcome to the movie theater!  Choose a seat.\n";    
    //get user input
    //check to see if the seat is occupied
    //get price of seat
    //charge for seat and mark it occupied
    //repeat til seats sold = total Seats
                      
    system("PAUSE");
    return EXIT_SUCCESS;
}
Last edited on
what is the use of this "using namespace" thing?
please reply soon
Last edited on
This should have been asked in a new thread as it has nothing to do with the original question, but as I'm feeling nice I won't ignore you...

Namespaces are a way of allowing "grouping" of code elements. So, for example, the function cout belongs to the "std" group and you will occassionaly see the use of double colons - which signifies the following command belongs to a particular namespace, eg;

 
    std::cout >> "hello world!"


What this means is that you could code your own version of cout and include it in your own namespace. If you called this namespace "mynamespace" then you could do the following in the same program as the above without the compiler being confused as to which version of cout you want to use;

 
    mynamespace::cout >> "hello world!"


Namespaces also make it possible to divide a program logically, for instance, if you were coding a game program, you could code all the routines for management of scenery in the "scene" namespace, and all the code for characters in the "character" namespace. It would then be very clear whether a particular piece of code was manipulating characters or scenery elements. So, for example, something like the following could be pretty helpful (you have to imagine that put_element() is defined separately in the two different namespaces;

1
2
    scene::put_element(tree, 100, 40)
    character::put_element(zothar, 100, 47)


Makes it kind of obvious that the first is putting a scenery element of type tree at location (100,40), the second is putting the character "Zothar" at (100,47). You don't need to use namespaces for this, of course, but it is one helpful approach.

Apart from this try reading the following;

http://www.cprogramming.com/tutorial/namespaces.html

And remember always, "Google is your friend"
Last edited on
Ummm...
I see a cout << "welcome...
but I don't see any cin >> ???
I also don't see any variable definition lines, sort of like: int i,j;
Topic archived. No new replies allowed.