Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming Pointers and Arrays. write a program to assign seats on each flight of the airlines only plane (capacity: 10 seats). Your program should

C Programming Pointers and Arrays.

write a program to assign seats on each flight of the airlines only plane (capacity: 10 seats). Your program should display a menu of alternatives:

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

If the person types 1, then your program should assign a seat in the first class section (seats 1 5). If the person types 2, then your program should assign a seat in the economy section (seats 6 10). Your program should then print a boarding pass indicating the person's seat number and whether its 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 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. If no, then print the message "Next flight leaves in 3 hours."

assume that the user wont enter anything other than a number for the menu choices or seat numbers.

Sample Output

-------------------------

Welcome to Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 3

SEATING CHART (0-Available, 1-Taken)

1 2 3 4 5 6 7 8 9 10

0 0 0 0 0 0 0 0 0 0

-------------------------

Welcome to Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 1

Enter your name (first name followed by last name): John Doe

Enter a seat number (1-5): 5

Congratulations, printing your boarding pass....

Airlines Boarding Pass

John Doe SEAT : 5

FIRST CLASS

-------------------------

Welcome to CES Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 3

SEATING CHART (0-Available, 1-Taken)

1 2 3 4 5 6 7 8 9 10

0 0 0 0 1 0 0 0 0 0

-------------------------

Welcome to Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 2

Enter your name (first name followed by last name): Jane Doe

Enter a seat number (6-10): 5

Choose a valid seat. Please choose another.

Enter a seat number (6-10): 6

Congratulations, printing your boarding pass....

Airlines Boarding Pass

Jane Doe SEAT : 6

ECONOMY

-------------------------

Welcome to Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 2

Enter your name (first name followed by last name): Jack Doe

Enter a seat number (6-10): 6

That seat is already taken. Please choose another.

Enter a seat number (6-10): 10

Congratulations, printing your boarding pass....

Airlines Boarding Pass

Jack Doe SEAT : 10

ECONOMY

-------------------------

Welcome to Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 3

SEATING CHART (0-Available, 1-Taken)

1 2 3 4 5 6 7 8 9 10

0 0 0 0 1 1 0 0 0 1

-------------------------

Welcome to Airline!

Please type 1 for first class

Please type 2 for economy

Please type 3 for seat chart

Please type 4 to quit

Your choice: 4

Goodbye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions