How to create a program that repeats itself?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Scripts in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!