How to get the the program to stop?

1 Ansicht (letzte 30 Tage)
Aaron
Aaron am 12 Jul. 2012
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?

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by