On 3/12/2013 11:45 PM, Christopher wrote: > Hey Guys, > > I have this homework question that I don't quite understand: > Suppose that a student has the option of enrolling for a single elective for a term. >The student must select a course from a limited list of options: "English", "History", >"Economy", "Chemistry" or "Physics". COnstruct a fragment of MATLAB code that >will prompt the student for his or her choice, read in the choice, and use >the answer as the case expression for a switch construct. Be sure to >include a default case to handle invalid input. > > Now I am not exactly sure what they are asking me to do. Can someone >nudge me in the right direction? Do the want me to list all of the > electives and then when the person chooses one to say "Congrats!" >or something? Any help would be much appreciated. Thanks >
I also think the question is not too clear.
But just read user input (make sure you use the 's' option), and do switch on each valid course, make sure you use string compare, and when one case fires just say
"Congrats! your selection" <the input> "was found, you are now enrolled"
The default will say something like
"no such course" <the input> "was found in our database, try again..."