hahaha....

i hope it doesn't have any error now...

thank you mr.....

bool is not accepted by the compiler borland c++.....

what is the header so that i can use the code bool

this is the only error i have.....

what will i do....


c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\planesas.cpp(46) : error C2143: syntax error : missing ',' before '.'

it has error on Borland.....

I dont know why the school uses Borland compiler, it is a primitive compiler....

what will i do to make it run on Borland

tnx...

bool is not accepted by the compiler borland c++.....
what is the header so that i can use the code bool

Aaahh, old compiler alert! (let me guess: You're from India?)
Anyway: change the word 'bool' to 'int' ; change 'true' to '1' (one) and 'false' to 0 (zero)

this is the only error i have.....

c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\planesas.cpp(46) : error C2143: syntax error : missing ',' before '.'

The code compiles fine on my machine. Did you change anything?

i am using the microsoft visual c++ 2008....

only one error appears because i change one error....

Post your current code.

i am from the philippines....

the error in Borland is

1.undefined function tupper in function main()

2. expression syntax in function main

3. while statement missing ) in function main

pleas.... i think it is almost finish...

tnx..

I'll tell you one more time:
Those errors aren't from the code I posted!

Do three things:

- Tell me if you have changed something
- Post your current code
- Do not change anything while I'm looking at it

#include<iostream>
using namespace std;

int main()
{
int reserve;

    char response = 'y';
    char ans;
    int choice;
    int seatNum;
    while (response != 'n' && response != 'N')
    while (toupper(response)!= 'N')
    {
        cout<<"Welcome to Tsai Airlines";
        cout<<"Would you like to reserve a seat in the smoking or non-smoking section of the airplane (s/n)?";
        cin>>ans;

        while(toupper(ans) != 'S' && toupper(ans) != 'N')
            {
            cout<<"Would you like to reserve a seat in the smoking or non-smoking section of the airplane (s/n)?";
            cin>>ans;

            }

        if(ans == 's')
        {
            cout<<"You have chosen the smoking section...Thank you!!!";
            cout<<"To select your own seat number, press 1";
            cout<<"To have the system select a seat for you, press 2";
            cin>>choice;

            while(choice != 1 && choice != 2)
            {

                cout<<"To select your own seat number, press 1";
                cout<<"To have the system select a seat for you, press 2";
                cin>>choice;
            }

            if(choice == 1)
            {
                cout<<"Please select your seat location (1-5): ";
                cin>>seatNum;

                while (int reserve.reserveSmoking(seatNum)=1);
                {

                    cout<<"Seat location<<seatNum<< is currently occupied!";
                    cout<<"To select your own seat number, press 1";
                    cout<<"To have the system select a seat for you, press 2";
                    cin>>choice;
                    while(choice != 1 && choice != 2)
                    {
                        cout<<"To select your own seat number, press 1";
                        cout<<"To have the system select a seat for you, press 2";
                        cin>>choice;
                    }
                }

            }

            else
            {
                cout<<"you have chosen in non smoking section";
            }

        }

    }

    return 0;
}

and here is my code in Borland....

#include<iostream.h>
#include<conio.h>

int main()
{
clrscr();
int reserve;

    char response = 'y';
    char ans;
    int choice;
    int seatNum;
    while (response != 'n' && response != 'N')
    while (toupper(response)!= 'N')
    {
        cout<<"Welcome to Tsai Airlines";
        cout<<"Would you like to reserve a seat in the smoking or non-smoking section of the airplane (s/n)?";
        cin>>ans;

        while(toupper(ans) != 'S' && toupper(ans) != 'N')
            {
            cout<<"Would you like to reserve a seat in the smoking or non-smoking section of the airplane (s/n)?";
            cin>>ans;

            }

        if(ans == 's')
        {
            cout<<"You have chosen the smoking section...Thank you!!!";
            cout<<"To select your own seat number, press 1";
            cout<<"To have the system select a seat for you, press 2";
            cin>>choice;

            while(choice != 1 && choice != 2)
            {

                cout<<"To select your own seat number, press 1";
                cout<<"To have the system select a seat for you, press 2";
                cin>>choice;
            }
            }

            if(choice == 1)
            {
                cout<<"Please select your seat location (1-5): ";
                cin>>seatNum;

                while (int reserve.reserveSmoking(seatNum)=-1);
                {

                    cout<<"Seat location<<seatNum<< is currently occupied!";
                    cout<<"To select your own seat number, press 1";
                    cout<<"To have the system select a seat for you, press 2";
                    cin>>choice;
                    while(choice != 1 && choice != 2)
                    {
                        cout<<"To select your own seat number, press 1";
                        cout<<"To have the system select a seat for you, press 2";
                        cin>>choice;
                    }
                }

            }

            else
            {
                cout<<"you have chosen in non smoking section";
            }

        }

    return 0;
}

i nedd the code in borland...

commented: You've wasted my time -1

Where did this code come from?

Lerner (and sort of me) gave you an excellent code to start with, but you chose to throw it away? That's great! You've just wasted 30 minutes of my day.

I'm not even going to start with this code, because by the time I found all the errors you probably re-wrote the entire thing again.

And as I mentioned earlier : use code tags when posting code!

[edit] And Joshmo also told you here

As did mirmkar here

ouch....

i had re write it and that "-" error always appear..

is the code you give, the overall code of the problem????

is the code you give, the overall code of the problem????

No, but it's a large step in the right direction.

The only things you'll have to add is
- a user-interface
- change '*' to 'X' (which is very simple if you would have a look at the code)

but i dont know how to make array function....

everyday i try it and i always got it wrong...

i had work on this for one week...

please help me...

day and night i work on it and its bad that you know your program doesnt work....

but i dont know how to make array function....

Ok. I'll try one more time. Look at the code I'll give you.
Study it for an hour or more.
Print it out an meditate on top of it.

If you understand how the code works, you're halfway done.

#include<iostream>

using namespace std;

const int ROWS = 13;
const int SEATS = 6;

//declaration of "function with array"
void initializePlane(char[ROWS][SEATS]); 
void printPlane(char[ROWS][SEATS]);

int main()
{

    bool result = true;
    char plane[ROWS][SEATS];

    initializePlane(plane);

    char ch;

    do
    {
        printPlane(plane);
        cout << "do again y/n";
        cin >> ch;
        if(ch != 'y')
          /*
         if you put something here like: 
         plane[1][1] = 'X';
         you will see that seat 1,1 has changed to 'x'
         */
            result = false;
    }while(result);

   cin.get();
    return 0;
}

// this is a function with an array as parameter
void initializePlane(char  plane[ROWS][SEATS])
{
    for(int x = 0; x < ROWS; x++)
    { 
        for(int y = 0; y < SEATS; y++)
        { 
            plane[x][y] = '*'; 
        } 
    }
}

// this is a function with an array as parameter
void printPlane(char  plane[ROWS][SEATS])
{ 
    cout<<"\t\t Airplane Seat Assignment"<<endl;

    for(int x = 0; x < ROWS; x++)
    { 
        for(int y = 0; y < SEATS; y++)
        { 
            cout << plane[x][y];

        } 
        cout<<endl;
    }
}

and its bad that you know your program doesnt work....

The code DOES work. It's not the answer to your homeworkproblem, but we don't give away homework.
Insulting people here is not the best way to get to an answer.

[edit]
If you're using the Borland Turbo compiler, you may have to change: #include<iostream> to: #include<iostream.h> I've been told that Turbo doesn't support the standard header

do i need to put #include<conio.h>

and

getch(); \\at the end..

do i need to put #include<conio.h>

and

getch(); \\at the end..

No. The cin.get(); will keep the console open.
If you are going to use cin >> in your program, you'll need to add cin.ignore() just above the cin.get()

ah... i will make a userInput function.... where will i put it????

I edited it on Borland and it run.....

tnk you...

will i put the userInput array inside the do while statement???

will i put the userInput array inside the do while statement???

Yup.
Here's another example (You'll have to adjust it yourself for your other program

#include<iostream>

using namespace std;

const int ROWS = 13;
const int SEATS = 6;

//declaration of "function with array"
void initializePlane(char[ROWS][SEATS]); 
int UserInput(char[ROWS][SEATS], int, int);
void printPlane(char[ROWS][SEATS]);

int main()
{

    bool result = true;
    char plane[ROWS][SEATS];
    initializePlane(plane);
    // show the initial plane:
     printPlane(plane);
    UserInput(plane, 1,1); //change seat 1,1 
    //after userinput:
    cout << "\nafter userinput\n\n";
    printPlane(plane);
    cin.get();
    return 0;
}

int UserInput(char plane[ROWS][SEATS], int row, int seat)
{
    /*first error checking!*/
    if (row>ROWS || row < 0 || seat>SEATS || seat <0)
        return 1; //error!
    else
        plane[row][seat] = 'X';
    return 0;
}

void initializePlane(char  plane[ROWS][SEATS])
{
    for(int x = 0; x < ROWS; x++)
    { 
        for(int y = 0; y < SEATS; y++)
        { 
            plane[x][y] = '*'; 
        } 
    }
}

void printPlane(char  plane[ROWS][SEATS])
{ 
    cout<<"\t\t Airplane Seat Assignment"<<endl;

    for(int x = 0; x < ROWS; x++)
    { 
        for(int y = 0; y < SEATS; y++)
        { 
            cout << plane[x][y];

        } 
        cout<<endl;
    }
}

when i input rows and column....

the print result are all X...

/*first error checking!*/
if (row>ROWS || row < 0 || seat>SEATS || seat <0)
return 1; //error!

what are this for????

when i input rows and column....

the print result are all X...

I gave it a try and there is one 'X' rest being '*'.

// output was
after userinput

                 Airplane Seat Assignment
******
*[B]X[/B]****
******
******
******
******
******
******
******
******
******
******
******

I.e. the expexted result. Are you sure you did not have that 'X' there?

can u at least put some spaces in between your sentences..

/*first error checking!*/
if (row>ROWS || row < 0 || seat>SEATS || seat <0)
return 1; //error!

what are this for????

Well, it is a check for valid ranges with regard to the array. You must not access any array out of bounds. Actually there is a slight error, it should be

if (row >= ROWS || row < 0 || seat >= SEATS || seat <0) 
{
     // improper value (out of bounds) for either row or seat
     // return a value that signifies an error ...
     return 1; //error!
}

E.g. if you have an array of size 5, the last valid index is four (4) not five, this is because array indexes start from zero. So, the following would be wrong

const int ARRAY_SIZE = 5;
int int_array[ARRAY_SIZE];

int_array[ARRAY_SIZE] = 123; // Wrong
int_array[ARRAY_SIZE - 1] = 123; // Right - sets the last int in the array to 123

Naturally array indexes are always non-negative, hence the check for e.g. row < 0 .

HOLY SMOKES

I'm glad i got out of this thread when I did.

(i saw it coming)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.