1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lukranit [14]
4 years ago
7

Write a program that can be used to assign seats for a commercial airline. The airplane has 13 rows, with 6 seats in each row.

Computers and Technology
1 answer:
Debora [2.8K]4 years ago
4 0

Answer: Provided in the explanation segment

Explanation:

The code below is provided to run this problem and solve this problem.

Code:

#include<stdio.h> //for printf and scanf

#include<stdbool.h> //for boolean datatype

char seats[13][6]; //2d char array represents seats of the airplane

//menu function prints the menu

void menu(){

printf("1) Display seats\n2) Reserve a seat\nEnter option: ");

}

//displayMap function prints the seat occupancies

void displayMap(){

int i,j;

printf("\n* - available\nX - occupied\n");

printf(" A B C D E F\n");

for(i=0;i<13;i++){

printf("%2d ",i+1);

for(j=0;j<6;j++){

printf("%c ",seats[i][j]);

}

printf("\n");

}

}

//validate returns true if seat is available, else returns false

bool validate(char c, int r){

if(c<'A'||c>'F'||r<1||r>13)

return false;

else if(seats[r-1][(int)(c-'A')]=='X')

return false;

return true;

}

//prompts user to enter seat no. then validates and reserves the seat

void makeReservation(){

char s[3],col;

int row = 0, i=1;

printf("Enter seat number (eg: A1 or C12): ");

scanf("%s",s);

col = s[0];

while(i<3&&s[i]!='\0'){

row = row*10 + (int)(s[i]-'0');

i += 1;

}

if(validate(col,row)){

seats[row-1][col-'A'] = 'X';

printf("%c%d is reserved for You. Thank you.",col,row);

}

else printf("%c%d reservation failed. Please check seat no. & try again!!",col,row);

}

//main function

int main()

{

int i,j,option;

//loops through the char array and assigns * to represent the seats are available

for(i=0;i<13;i++){

for(j=0;j<6;j++){

seats[i][j] = '*';

}

}

do{ //loop continues until user enters neither 1 nor 2

menu(); //calls menu function

scanf("%d",&option);

if(option==1){ //if option is 1 then displayMap function is called

displayMap();

}

else if(option==2){ //if option entered is 2 then makeReservation function gets called

makeReservation();

}

printf("\n\n");

}while(option==1||option==2);

printf("Thank you for using our service\n");

  return 0;

}

Cheers i hope this helped !!

You might be interested in
_______ imaging technology defines locations in the brain where neurons are especially active using safe radioactive isotopes to
Radda [10]

Answer:

Positron Emission Tomography (PET)

Explanation:

4 0
3 years ago
Read 2 more answers
python Which data type is the best choice to store the number of wins associated with each basketball team in the NBA
Sveta_85 [38]

Answer:

integer

Explanation:

this data type must be  a number, but it will always be  a whole number, so boolean is not appropriate. This means that it will be integer data type

4 0
3 years ago
Read 2 more answers
13. Microsoft PowerPoint is the best example of Multimedia Presentation
marissa [1.9K]

Answer:

Uhhh...ooop.........

7 0
4 years ago
Read 2 more answers
Which framework can be used to develop cross-platform applications?
k0ka [10]

Answer:

Qt framework

Explanation:

3 0
3 years ago
⦁ Consider transferring an enormous file of L bytes from Host A to Host B. Assume an MSS of 536 bytes. ⦁ What is the maximum val
timurjin [86]

Answer:

a)  There are approximately  2^32 = 4,294,967,296 possible number of the sequence. This number of the sequence does not increase by one with every number of sequences but by byte number of data transferred. Therefore, the MSS size is insignificant. Thus, it can be inferred that the maximum L value is representable by 2^32 ≈ 4.19 Gbytes.

b)  ceil(2^32 / 536) = 8,012,999

The segment number is 66 bytes of header joined to every segment to get a cumulative sum of 528,857,934 bytes of header. Therefore, overall number of bytes sent will be 2^32 + 528,857,934 =  4.824 × 10^9 bytes.  Thus, we can conclude that the total time taken to send the file will be 249 seconds over a 155~Mbps link.

Explanation:

a)  There are approximately  2^32 = 4,294,967,296 possible number of the sequence. This number of the sequence does not increase by one with every number of sequences but by byte number of data transferred. Therefore, the MSS size is insignificant. Thus, it can be inferred that the maximum L value is representable by 2^32 ≈ 4.19 Gbytes.

b)  ceil(2^32 / 536) = 8,012,999

The segment number is 66 bytes of header joined to every segment to get a cumulative sum of 528,857,934 bytes of header. Therefore, overall number of bytes sent will be 2^32 + 528,857,934 =  4.824 × 10^9 bytes.  Thus, we can conclude that the total time taken to send the file will be 249 seconds over a 155~Mbps link.

8 0
3 years ago
Other questions:
  • _____ view focuses on the text and content of a document, without much information on the page layout
    15·1 answer
  • Which different supports from a part of the matte box?
    8·1 answer
  • Why is Brainly always deleting either my answers or my questions? I am putting nothing inappropriate in them. Can someone answer
    7·2 answers
  • ) Briefly describe the purpose of the DASH protocol in streaming videos.
    9·1 answer
  • Consider the following threats to Web security, and describe how each is countered by a particular feature of SSL.
    15·1 answer
  • Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates R1 = 500 kbps, R2
    14·1 answer
  • I get such an error when I turn on the computer, how can I fix it?
    7·1 answer
  • How will Artificial Intelligence change the way we do things? .......C-Claim:
    10·1 answer
  • So, I have an Cru__ on this boy in school and his name is Bray but Yeah.............Can someone help me
    10·2 answers
  • Select the correct answer from each drop-down menu. Computer memory stores data as a series of 0s and 1s. In computer memory, re
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!