Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Please help me to slove this problem!!!!

Subject: Please help me to slove this problem!!!!

From: Ijat

Date: 6 Apr, 2009 08:07:02

Message: 1 of 2

Question
A small bus company has just purchased a computer for its new automated reservations system.The owner of the company has asked you to program the new system.You are to write a program to assign seats on each bus with capacity of 40 seats.You program should display the following menu of alternatives.

Please type 1 for “VIP seat”
Please type 2 for “economy seat’

If the person types 1,then your program should assign a VIP seat section (seat 1-26).If the person types 2,then your program should assign a seat in the economy section(seat 27-40).Your program should then print a ticket including the passenger seat class and the seat number on the same ticket.

Use a single-subscripted array to represent the seating chart of the bus.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 indicate that the seat is no longer available.


Your program should never assign a seat that has already been assigned.Your program also has to show the message “VIP seat SOLD OUT” if seat in VIP class is full and the message “economy seat SOLD OUT” if seat in economy class is full.

My answer is :
x=input ('Enter your seat : ');
if x==1
    disp('VIP seat');
else
    disp ('Economy seat');
end
x=input ('Select Your Seat:');
if x<0
    disp ('number you enter invalid');
elseif x<27
    disp('VIP Seat');
elseif x<40
    disp('Economy Seat');
else
    disp('number you enter invalid');
end
x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
end
y=[0,2,3,0,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,24,0,26];
a=(x~=y)
x=[27,28,29,30,31,32,33,34,35,36,37,38,39,40];
l=[27,28,29,0,0,0,0,0,0,0,0,0,39,40];
b=(x~=l)
x=input ('Select Your Seat:');
if x<0
    disp ('number you enter invalid');
elseif x==1,4,7,8,9,10,11,12,13,14,15,16,17,18,19,23,25
    disp('VIP seat is SOLD OUT');
elseif x==30,31,32,33,34,35,36,37,38
    disp('Economy seat is SOLD OUT');
elseif x==2,3,20,21,22,24,26,27,28,29,39,40
else
    disp('number you enter invalid');
end
   
Please give me the right command..!!!
Help me!!
please...
It's between the life and death!!!
we will dismiss!!!

Subject: Please help me to slove this problem!!!!

From: Gavrilo Bozovic

Date: 6 Apr, 2009 08:26:01

Message: 2 of 2

"Ijat " <darkness_roses90@yahoo.com> wrote in message <grcd75$q9k$1@fred.mathworks.com>...
> Question
> A small bus company has just purchased a computer for its new automated reservations system.The owner of the company has asked you to program the new system.You are to write a program to assign seats on each bus with capacity of 40 seats.You program should display the following menu of alternatives.
>
> Please type 1 for “VIP seat”
> Please type 2 for “economy seat’
>
> If the person types 1,then your program should assign a VIP seat section (seat 1-26).If the person types 2,then your program should assign a seat in the economy section(seat 27-40).Your program should then print a ticket including the passenger seat class and the seat number on the same ticket.
>
> Use a single-subscripted array to represent the seating chart of the bus.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 indicate that the seat is no longer available.
>
>
> Your program should never assign a seat that has already been assigned.Your program also has to show the message “VIP seat SOLD OUT” if seat in VIP class is full and the message “economy seat SOLD OUT” if seat in economy class is full.
>
> My answer is :
> x=input ('Enter your seat : ');
> if x==1
> disp('VIP seat');
> else
> disp ('Economy seat');
> end
> x=input ('Select Your Seat:');
> if x<0
> disp ('number you enter invalid');
> elseif x<27
> disp('VIP Seat');
> elseif x<40
> disp('Economy Seat');
> else
> disp('number you enter invalid');
> end
> x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
> end
> y=[0,2,3,0,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,24,0,26];
> a=(x~=y)
> x=[27,28,29,30,31,32,33,34,35,36,37,38,39,40];
> l=[27,28,29,0,0,0,0,0,0,0,0,0,39,40];
> b=(x~=l)
> x=input ('Select Your Seat:');
> if x<0
> disp ('number you enter invalid');
> elseif x==1,4,7,8,9,10,11,12,13,14,15,16,17,18,19,23,25
> disp('VIP seat is SOLD OUT');
> elseif x==30,31,32,33,34,35,36,37,38
> disp('Economy seat is SOLD OUT');
> elseif x==2,3,20,21,22,24,26,27,28,29,39,40
> else
> disp('number you enter invalid');
> end
>
> Please give me the right command..!!!
> Help me!!
> please...
> It's between the life and death!!!
> we will dismiss!!!

What is the problem you're having?

No one will read carefuly the question, then read carefuly your code, and then do your homework for you.

Come with a precise question, and you'll get a precise answer. Also, state clearly in the subject what your problem is.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us