How to create a program that repeats itself?
显示 更早的评论
I want this program to repeat itself after giving an output (ask input again and calculate again). I don't know how to do that can someone help me?
t=36; %total number of lectures
b=0;
while b==0
p=input('Enter Number of Lectures Attended \n');
if p>36
fprintf('Error, note that the total number of lectures are 36. \n')
else
b=1;
end
end
a=(p/t)*100; % this calculates the percentage attendance
if a>=75
fprintf('The student does not have short attendace. \n')
else
fprintf('The student has short attendace. \n')
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Scripts 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!