Question

MATLAB PROGRAM: (Conditional if and switch).  You must prepare the code (instructions) in Matlab for the following...

MATLAB PROGRAM:

(Conditional if and switch).  You must prepare the code (instructions) in Matlab for the following problem.

A person weighs 72 kg and wants to know how many calories he spends during the time he performs the same activity. The activities that you are allowed to do are just sleeping or sitting at rest. The data he has are: a) while sleeping he consumes 1.06 calories per minute and b) while sitting at rest he consumes 1.68 calories per minute. Ask the user the activity they are doing and the time they will do it and show the calories spent.

Thank you!

Homework Answers

Answer #1

activity=input('Enter activity(sleeping,sitting): ','s');
t=input('Enter time(in minutes): ');
if strcmpi(activity,'sleeping')
fprintf('Calories spent: %f\n',t*1.06)
elseif strcmpi(activity,'sitting')
fprintf('Calories spent: %f\n',t*1.68)
else
fprintf('Invalid activity entered\n')
end

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
Employment Law Instructions · You must clearly identify the question you are answering in each of...
Employment Law Instructions · You must clearly identify the question you are answering in each of your answers. · You will be able to answer the questions based on the course materials (the text book, the Fair Work Act 2009 and the readings provided on Moodle). Referencing Please write your answers with reference to the relevant case law and legislation. · When you refer to a provision in the legislation, you must cite the provision and the legislation (eg s...
21. A client who was admitted with pneumonia was complaining of abdominal pain from frequent non-...
21. A client who was admitted with pneumonia was complaining of abdominal pain from frequent non- productive coughing. When he does produce sputum, it is watery and yellowish-green. Which of the following are appropriate nursing interventions at this time? Select all that apply Give him a pillow for splinting Administer antitussive syrup, 30mg ordered prn. Place him in appropriate positions for postural drainage Encourage him to increase his oral fluid intake Request an order for increasing flow rate. 22. A...
The Business Case for Agility “The battle is not always to the strongest, nor the race...
The Business Case for Agility “The battle is not always to the strongest, nor the race to the swiftest, but that’s the way to bet ’em!”  —C. Morgan Cofer In This Chapter This chapter discusses the business case for Agility, presenting six benefits for teams and the enterprise. It also describes a financial model that shows why incremental development works. Takeaways Agility is not just about the team. There are product-management, project-management, and technical issues beyond the team’s control. Lean-Agile provides...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT