Azzera filtri
Azzera filtri

How to get the the program to stop?

3 visualizzazioni (ultimi 30 giorni)
Aaron
Aaron il 12 Lug 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?

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by