How to get the the program to stop?

1 次查看(过去 30 天)
Aaron
Aaron 2012-7-12
I'm creating a program and need it to stop at a prompted number.
if true
% code
end
*n = input('Enter number of grades in range: ');
while n<0
x=input('Enter grade(0 to 100): ');
if x >= 90
fprintf('Grade = %0.0f,A\n',x)
elseif x >= 80
fprintf('Grade = %0.0f,B\n',x)
elseif x >= 70
fprintf('Grade = %0.0f,C\n',x)
elseif x >=60
fprintf('Grade = %0.0f,D\n',x)
else
fprintf('Grade = %0.0f,F\n',x)
end
if x<0
end
end*
After prompting the user to enter the number of grades, n, I need my while loop to stop after that number of entries of x.
Could I use an array for this? Or is what I have okay?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by