I have to write a C program to assign seats on each flight of the airline’s…

I have to write a C program to assign seats on
each flight of the airline’s…

I have to write a C program to assign seats on
each flight of the airline’s only plane (capacity: 40 seats, in 10
rows). For the sake of simplicity, assume that each row has 4 seats
labeled A, B, C, D. Your program should display the following menu
of alternatives: Please type 1 for “first class” Please type 2 for
“business class” Please type 3 for “economy class”. If the person
types 1, then your program should assign a seat in the first class
section (rows 1-2). If the person types 2, then your program should
assign a seat in the business class section (seats 3-4). If the
person types 3, then your program should assign a seat in the
economy section (seats 5–10).
Your program should print:
(1) the seating map/chart showing all 40 seats and indicating if
each seat is filled, (2) prints a passenger manifest showing names
of all passengers and their seat numbers in a tabular format, and
(3) prints a boarding pass for a chosen passenger indicating the
person’s name, seat number (For example: 2B) and whether it’s in
the first class or business class, or economy section of the plane.
Use a double-subscripted (2D) 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 element 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’s
acceptable to be placed in the business class. Similarly, if the
business section is full, ask the user if economy section is
acceptable. Similarly, user should have the choice of upgrading to
business class or first class if a seat is available. If user
chooses to change his/her choice, then make the appropriate seat
assignment. If no seat is available in chosen section, then print
the message “Next flight leaves in 3 hours”
Here is my code below. I can assign seats, print all
seats if assigned or not, find a person based on their seat. I
cannot however figure out the upgrades to different classes, the
next flight leaves in 3 hours message, and the boarding pass. Also
function find_seat_in_section has not been completed.
#include

#include

#define NUM_ROWS 10

#define SEATS_PER_ROW 4

#define MAX_NAME_LENGTH 50

//array seats represents seats on the plane.

//we take advantage of the fact that c initializes values of global
variables to be zero

//so no explicit initialization is needed

int seats[NUM_ROWS][SEATS_PER_ROW];

char passengers[NUM_ROWS][SEATS_PER_ROW][MAX_NAME_LENGTH +
1];

void print_seats(){

   printf(” A B C Dn”);
   int row;

   for(row = 0; row < NUM_ROWS; row += 1){        int seat;        printf("Row %2d: ", row+1);        for(seat = 0; seat < SEATS_PER_ROW; seat += 1){            //we get to here for every seat in every row            //printf("%d(%d,%d) ", seats[row][seat], row, seat);            if(seats[row][seat] == 0){                printf(". ");            }            else {                printf("$ ");            }        }        printf("n");    }    } void print_manifest(){    int row;    for(row = 0; row < NUM_ROWS; row += 1){        int seat;        for(seat = 0; seat < SEATS_PER_ROW; seat += 1){                       if(seats[row][seat] == 1){                printf("%-55s %d%cn", passengers[row][seat], row+1, 'A' + seat);            }                   }    }    } int assign_seat_in_section(int first_row, int last_row, int assigned[]){    int row;    int seat;    for(row = first_row; row <= last_row; row += 1){        for(seat = 0; seat < SEATS_PER_ROW; seat += 1){            if(seats[row][seat] == 0){                seats[row][seat] = 1;                assigned[0] = row;                assigned[1] = seat;                //printf("Found an empty seat at: row%d and seat%dn", row, seat);                return 1;            }        }    }    return 0; } int find_seat_in_section(int first_row, int last_row, int assigned[]){    int row;    int seat;    for(row = first_row; row <= last_row; row += 1){        for(seat = 0; seat < SEATS_PER_ROW; seat += 1){            if(seats[row][seat] == 0){                assigned[0] = row;                assigned[1] = seat;                //printf("Found an empty seat at: row%d and seat%dn", row, seat);                return 1;            }        }    }    return 0; } int main() {    printf("Size of seats: %zdn", sizeof(seats)/sizeof(int));    printf("Size of seats per row: %zdn", sizeof(seats [0])/sizeof(int));    print_seats();    while(1){        printf("Please type 1 for first classn"            "Please type 2 for business classn"            "Please type 3 for economy classn");        int class, got_it, assigned[2];        scanf("%d", &class);        if(class ==1){            got_it = assign_seat_in_section(0,1,assigned); //would assign seat in first class            if(got_it == 0){                got_it = assign_seat_in_section(2,3,assigned); //would assign seat in business class                if(got_it == 0){                    got_it = assign_seat_in_section(4,9,assigned); //would assign seat in economy class                }            }                   }        else if (class == 2){            got_it = assign_seat_in_section(2,3,assigned);        }        else if(class == 3){            got_it = assign_seat_in_section(4,9,assigned);        }        if(got_it == 1){            int row = assigned[0];            int seat = assigned[1];            printf("Assigned Seat: %d%cn", row+1, 'A' + seat);            printf("What is your name?");            char name[MAX_NAME_LENGTH + 1];            scanf(" %[A-Za-z ]", name); //scan set for letters and blanks            printf("Name is %sn", name);            strcpy(passengers[row][seat], name);        }        print_seats();        print_manifest();        printf("To find out where someone is sitting, enter the seat number (e.g. 1A): ");        char who[10];        scanf("%s", who);        int row = atoi(who) - 1;        int seat = who[strlen(who) - 1] - 'A';        printf("Row = %d, %d %sn", row, seat, passengers[row][seat]);               //find_seat_in_section(specific rows per section);           } } /* For upgrade, need to know if seat is available before offering an upgrade, write a function like assigned seat except it doesnt assign a seat, it returns 1 if a seat is available, and puts the row and column in the assigned array */

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Covid-19 Update

Guys, Coronavirus is reshaping education. Our mission is to provide you with the best online writing solutions. We operate around the clock, 24/7 to ensure that you get the best from us. Feel free to order your papers as usual. Keep Safe