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!
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
Get Answers For Free
Most questions answered within 1 hours.