Write a function (seat_type) that reads an input from the user that represents a seat class. The user should enter F: for a first class seat, C: for a business class seat, or Y: for an economy seat. The function should validate the user input to accept only F, C, or Y.
yassink 0 Newbie Poster
Recommended Answers
Jump to PostWhat do you have so far?
Jump to Post
while ( (z != "F") || (z != "C") || (z != "Y") )
Can you give me a value of z for which this will not be true? Any value at all - give me one letter that will make the while loop stop.
Jump to PostAny letter other than F, C or Y?
None of those letters will make it stop.
Also, you're trying to work with a single letter. Use the char type, not int. You'll make your life so much easier.
Also,
"F"
is a string - a pointer to a …
Jump to PostAny letter inserted other than these 3 capitalised letters will stop the loop.
No. Nothing will make that loop stop. It will loop forever.
Let's say you enter the letter
F
.(z != "F") - This is FALSE.
(z != "C") - This is TRUE.
(z != "Y") …
All 14 Replies
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
aradicev 0 Newbie Poster
yassink 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yassink 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yassink 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yassink 0 Newbie Poster
yassink 0 Newbie Poster
k99rs 9 Newbie Poster
mridul.ahuja 4 Coding Enthusiast
RonalBertogi 46 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.