2. Use a script file to create a program that prompts the user to enter a scalar
ID: 2087399 • Letter: 2
Question
2. Use a script file to create a program that prompts the user to enter a scalar value for the outside air temperature. If the user enters a vector value or a negative temperature, use the error function to report an error. If the temperature is equal to or above 80°F, send a message to the command window telling the user to wear shorts. If the temperature is between 60 F and 80°HF, send a message to the command window telling the user that t is a beautiful day. If the temperature is equal to or below 60°F, send a message to the command window telling the user to wear a jacket or a coat. Test all possible cases to demonstrate that your program works well.Explanation / Answer
x=input('Enter outside temprature:');
if(x<0)
error(invalid temprature);
if(x>=80)
disp('wear shorts');
if(x>60&x<80)
disp('it is a beautiful day');
elseif(x<=60)
disp('wear a jacket or coat');
end
output:-
Enter outside temprature:90
wear shorts
Enter outside temprature:70
it is a beautiful day
Enter outside temprature:59
wear a jacket or coat
Enter outside temprature:-10
invalid temprature
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.