MATLAB The user is supposed to enter either a ‘yes’ or ‘no’ in response to a prompt....

50.1K

Verified Solution

Question

Mechanical Engineering

MATLAB

The user is supposed to enter either a ‘yes’ or ‘no’ in responseto a prompt. The script will print “OK, continuing” if the userenters either a ‘y’, ‘Y’,'Yes', or 'yes' or it will print “OK,halting” if the user enters a ‘n’, ‘N’, 'No', or 'no' or will print“Error” if the user enters anything else.

Code this twice once with if and once withswitch:

Then recode the example above to keep promptinguntil an an acceptable yes or no is entered:

What loop should we use?

what should we intialize?

please generate all code for Matlab

Answer & Explanation Solved by verified expert
3.9 Ratings (554 Votes)
If Part Code prompt Do you want to continue or not inputuser inputprompts if inputuser y inputuser Y inputuser yes inputuser YES dispOK continue elseifinputuser n inputuser N inputuser no inputuser NO dispOK halting else dispError end    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students