Borrar filtros
Borrar filtros

How to get the the program to stop?

3 visualizaciones (últimos 30 días)
Aaron
Aaron el 12 de Jul. de 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?

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by