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

In a script, the user is supposed to enter either a \'y\' or \'n\' in response t

ID: 3826171 • Letter: I

Question

In a script, the user is supposed to enter either a 'y' or 'n' in response to a prompt. The user's input is read into a character variable called "letter." The script will print "OK, continuing" if the user enters either a 'y' or 'Y or it will print "OK, halting" if the user enters a 'n' or 'N' or "Error" if the user enters anything else. Put this statement in the script first: letter = input ('Enter your answer: ' 's') Write the script using a single nested if-else statement (elseif clause is permitted).

Explanation / Answer

letter = input('Enter your answer: ', 's')
if xor(letter=='y',letter=='Y')
   disp('OK, continuing')
elseif xor(letter=='n',letter=='N')
   disp('OK, halting')
else disp('ERROR')
end

You can modify the first line as below for better visibility:
letter=input('Please enter the letter (Y/N):','s')

Please Rate Well, Good Luck!

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