Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB 14.8 Structure example: Seat reservation system A programmer commonly uses structures, arrays, and functions together. Consider a program that allows a reservations agent to

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedMATLAB

14.8 Structure example: Seat reservation system A programmer commonly uses structures, arrays, and functions together. Consider a program that allows a reservations agent to reserve seats for people, such as for a theater, an airplane, etc. The below program defines a seat structure whose fields are a person's first name, last name, and the amount paid for the seat. The program creates an array of structures allseats, and then allows a user to enter commands to print all seats, reserve a seat, or quit. Figure 14.8.T: Main script. % Assign default menu value userKey = 'go'; disp( 'Reservation System for 5 seats % Define an array of 5 empty seats al!Seats MakeAllSeatsEmpty (5); = % Continue to prompt user for menu selection while not quit while -strcmp (userKeyq) fprintf (' ') % Print empty line userKey input( Enter command (p/r/g): % Print all seats in array % Print each seat's information if strcmp (userKey, p') PrintAllseats (allSeats); elseif stromp(userKey, % Reserve a seat seatNumber = input (Enter seat number : ' ); % Get seat number if CheckSeatEmpty (allseats (seatNumber)) % Check if seat is empty a11seat s (seatNumber) Reserveseat(); % If empty, Reserve seat = else % If not empty, display error message fprintf (Seat %d is not empty. ', seatNumber) end

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

0 . 1 9 is 1 0 times as great as 0 . 0 1 9

Answered: 1 week ago