In: Computer Science
using matlab:
1- Using ‘input’ command, ‘prompt’ your name and ask for a grade (A, B, C, D, F should be accepted only, otherwise it should ask again)
2- Use ‘display’ command for the previous problem and display your name and your grade
Please follow the code and comments for description :
CODE :
prompt = 'What is your Name.? '; % prompt for the name
str = input(prompt,'s'); % read the data using the input
command
prompt1 = 'What is your Grade.? '; % prompt for the grade
str1 = input(prompt1,'s'); % read the data using the input
command
while 1 % itarate over the while loop consition is satisfied
prompt1 = 'What is your Grade.? '; % re prompt
the grade
str1 = input(prompt1,'s'); % read the data using
the input command
if ((str1 == 'A') || (str1 == 'B') || (str1 ==
'C') || (str1 == 'D') || (str1 == 'F')) % check for the
condition
break % break the loop
if condition is satisfied
end
end
% display the data entered
display('Your Name is : ');
display(str);
display('Your Grade is : ');
display(str1);
OUTPUT :

Hope this is helpful.