Assume the following 3 variables describe a set of variables: Weather – A numeri
ID: 675528 • Letter: A
Question
Assume the following 3 variables describe a set of variables:
Weather – A numeric value between 20 and 120
Schedule – A numeric value between 0 and 5 that indicates your “business”. 0 means
nothing going on, 5 means “packed schedule”
LikeRunning – A numeric value between 0 (hate running) and 10 (love running)
Write a MATLAB script that:
i) ii)
a. b.
Inputs 3 values for the 3 variables
Checks if the values belong in the predefined range
If all the values are within the predefined range, display “Going for a Run” or “Not going for a Run” based on the values of these variables.
Else display a message to to user informing about the mistake with the input values
The logic that determines which output to display is given by the following flowchart:
No Display "Not going for a Run LikeRunning>4 Yes No No Display "Not Going for a Run Schedule >2 45cWeatherc90 Yes Yes Display "Not going for a Run Display "Going for a Run"Explanation / Answer
weather = input('Enter the weather within the range 20 and 120: ');
schedule = input('Enter the schedule within the range 0 and 5 : ');
likeRunning = input('Enter your liking on a 10 point scale, 0 for hate running, 10 for love running: ');
if((weather < 20 || weather > 120) || (schedule < 0 || schedule > 5) || (likeRunning < 0 || likeRunning > 10))
display 'Input values are out of range. Please follow the prompt.';
else
if(likeRunning >= 4)
if(schedule > 2)
display 'Not going for a run.';
else
if(weather > 45 && weather < 90)
display 'Going to run.';
else
display 'Not going for a run.';
end
end
else
display 'Not going for a run.';
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.