Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a script that has a fireman respond yes or no to being asked whether he s

ID: 3588827 • Letter: C

Question

Create a script that has a fireman respond yes or no to being asked whether he sees a book. If he answers yes, then set the book burning temperature to 451. If he responds no, then ask if he wants to continue looking. If he says yes, have the process start over. If he says no, set the book burning temperature to 0, and print out to the user ‘No books to burn today’.

(in MATLAB )

this is what I have and when i input 'yes' nothing happens and when i input 'no' it says "matrix must agree error line 2"

answer = input('do you see a book?');
if answer == 'yes'
bookBurningTemp = 451;
else answer == 'no'
choice = fprintf('do you want to keep looking?');
if choice == 'yes'
fprintf('i dont know how to start the process over');
else choice == 'no'
bookBurningTemp = 0;
fprintf('no books to burn today. ');
end
end

Explanation / Answer

%matlab code

% string input is taken by prompting and converting input to string using 's'

answer = input('do you see a book? ' , 's');

bookBurningTemp = 0;

% if else statements are corrected

if strcmpi('yes',answer)

bookBurningTemp = 451;

fprintf('Buring Temperature: %d ',bookBurningTemp);

elseif strcmpi('no',answer)

% take input using input statment like done at start of program

choice = input('do you want to keep looking? ', 's');

ifstrcmpi('yes',choice)

fprintf('I dont know how to start the process over');

elseif strcmpi('no',choice)

bookBurningTemp = 0;

fprintf('No books to burn today. ');

end

end


%output:
do you see a book? yes
Buring Temperature: 451


Let me know in comments if you are still facing any issues

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote