Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Homework Help
Replies: 1   Last Post: Mar 13, 2013 3:56 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Nasser Abbasi

Posts: 5,675
Registered: 2/7/05
Re: Homework Help
Posted: Mar 13, 2013 3:56 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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..."

--Nasser









Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.