need help with c++

hi, im having trouble with getting a certain program to work. Its probably a really simple problem, but i just can't get it to work! I'll seriously pay someone like $5 to do this in c++ by tonight =D just give me yer paypal!

white a program for...
(Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. You have been asked to program the new system. You are to write a program to assign seats on each flight of the airline’s only plane (capacity: 10 seats).
Your program should display the following menu of alternatives— Please type 1 for "First Class" and Please type 2 for "Economy". If the person types 1, your program should assign a seat in the first class section (seats 1-5). If the person types 2, your program should assign a seat in the economy section (seats 6-10). Your program should print a boarding pass indicating the person’s seat number and whether it is in the first class or economy section of the plane.
Use a single-subscripted array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.
Your program should, of course, never assign a seat that has already been assigned. When the first class section is full, your program should ask the person if it is acceptable to be placed in the nonsmoking section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message "Next flight leaves in 3 hours."



Answer this question

need help with c++

  • lucoosa

    #include "stdafx.h"

    #include <iostream>

    using std::cout;

    using std::endl;

    using std::cin;

    int main()

    {

    int choice;

    char ptr;

    int i = 0;

    int k;

    int seating[10] = {0,0,0,0,0,0,0,0,0,0};

    int *pptr = seating;

    for (int i=0; i<10; i++){

    cout<<"Please type 1 for first class or 2 for economy class"<<endl;

    cin>>choice;

    if ((choice == 1)&&(ptr == 0)){

    k = i+1;

    seating[ i ] = k;

    cout<<"your seat number is: "<<seating[ i ]<<" and you are in first class"<<endl;

    }

    else {

    cout<<"your seat number is: "<<seating[ i ]<<" and you are in economy class"<<endl;

    }

    }

    return 0;

    }

    ok, this is what i have so far AND good call with the pointer.. that can check if the value in the array is 0 or not right   This way if the value is 1 that means the seat is taken, and if its not, then it till be able to seat that person!  what im still not getting is, how do i set the value in each spot to the array to a 1 or 0 after each person takes a seat did i set up the loop right this time im confused

  • Crux

    If you want to change it from a zero to a one at a specific seat, just do something like this:

    int seat_taken;

    seating[seat_taken] = 1;



  • ASunar

    First in your for loop x=0, x<11 which gives me an option to select between 0to 10 which is 11 seats.

    I would recommend that you read this stuff on how to operate with arrays

    http://msdn2.microsoft.com/en-us/library/1wz9z5b3(VS.80).aspx

    thanks


  • Frank M. Palinkas

    lol good points.. I've just been trying this for about 8 hours now and am just getting so frustrated. I dont have my book to look up how to do the array thats needed and this is my last project thats due tomorrow! Thanks for the link though, that sites pretty cool lol!
  • Ben Music

    omgggg thank you!! send me yer paypal to wishkah353@adelphia.net
  • patria

    Hi, welcome to the forums. Some observations

    1 - this is your homework. If I do it for you, I rob you of the chance to learn what you need to learn to do your next assignment. Eventually, you would graduate, and still be unqualified.

    2 - these forums are for helping people. If you want to pay someone to do your work for you ( and eventually work at McDonalds ), you should try www.rentacoder.com. If you want to pass your course, you should try to do this, and ask *specific* questions when you get stuck. Post your code, along with an explanation of why you're stuck, and lots of people here will help you

    3 - If I was to charge you my going rate to do this work for you, it would be a LOT more than $5. That's because people who work hard when they are at school end up doing well for themselves. Another reason you should do your own homework.



  • Ooo

    nt choise;
    int classone[5]={1,2,3,4,5};
    int classtwo[5]={66,77,88,99,11};
    int j = 0;
    int x = 0;
    for(int i = 0; i <=10; i++)
    {

    cin >> choise;

    if(choise == 1)
    {
    if(x>4)
    {
    cout << "First class out of order" << endl;
    break;
    }
    cout << classone[x] << "nd Seat ***First class*** ordered" << endl;
    x++;
    }//if

    if(choise==2)

    {
    if(j>4)
    {
    cout << "Second class out of order" << endl;
    break;

    }
    cout << classtwo[j] << "nd Seat **Second class** ordered" << endl;
    j++;
    }//if

    }
    return 0;
    }

  • betaalpha

    Firstly you have to read the question properly. They are saying to have "one" array with the elements initialised to zero.

    int seating[10] = { 0, 0, …, etc };

    This gives you an index range [0 – 9]. Each time you assign a seat you change a "0" for a "1" to indicate its taken.

    The rest is down to you, because you’ve already run up a bill of $100,000 just for this help and I don’t really want to bankrupt you at such a young age.

    But honestly, go through the question and pick out the key words. Also be prepared to make some assumptions of your own, you have 10 seats, how are they laid out on the plain, so which are the smoking / non-smoking seats, the simplest layout is the best unless you're told to be fancy.


  • Ryan Kinderman

    lol dayum 100k for this !

    ok, that makes it a little easier to set up the array.. any chance i could get a little more help on how to assign the 1 to the array

    if i have..

    int seating[10] = {0,0,0,0,0,0,0,0,0,0};

    how would i set up the line to change one of the 0's to a 1 And how do i make it so it wont use the same seat once it is a 1

    thanks for the response btw.. im seriously going insane trying to get this to work!


  • Peter of Mountsorrel

    don't put a valid email address, some spam companies use software to scan forums for these and then ..., well you can guess what will happen. Instead do something like wishkah353@_JUNK_BIT_adelphia.net and if people want to contact you they can remove the unrequired bit. So edit that post of yours.
  • GoldenBrown2

    heres where i get stuck..

    do i do this

    #include "stdafx.h"

    #include <iostream>

    using std::cout;

    using std::endl;

    using std::cin;

    int main()

    {

    int x;

    int choice;

    int firstClass[5] = {1, 2, 3, 4, 5};

    int secondClass[5] = {6, 7, 8, 9, 10};

    for (x = 1; x < 11; x++);

    {

    cout<<"Please type 1 for first class or 2 for economy class"<<endl;

    cin>>choice;

    if (choice == 1)

    // am i on the right path


  • Lalit Dubey

    ok i think i got it now... i just need to know how to set up the loop!

    for (int x = 0; x < 11; x++){

    ...etc

    if (choice == 1){

    i = i+1

    seatingIdea = 1;

    cout<<"your choice is first class and your seat is "<<seating Idea<<endl;

    this is hard to explain, but am i getting closer


  • need help with c++