Q:

Write a script that will prompt the user for a quiz grade and error-

0

Write a script that will prompt the user for a quiz grade and error-

check until the user enters a valid quiz grade. The script will then echo print the grade. For this case, valid grades are in the range from 0 to 10 in steps of 0.5. Do this by creating a vector of valid grades and then use any or all in the condition in the while loop.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch5Ex33.m

% Prompt the user for a quiz grade and error-check

% until a valid grade is entered; using any or all

quiz = input('Enter a quiz grade: ');

validgrades = 0: 0.5: 10;

while ~any(quiz == validgrades)

 quiz = input('Invalid! Enter a quiz grade: ');

end

fprintf('The grade is %.1f\n', quiz)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now