📅  最后修改于: 2021-01-07 02:10:01             🧑  作者: Mango
if expression
Statements
end
% program to announce bonus on max hour of job
a = randi(250,12,2)
pr = 0;
bonus = 10000;
for k = 1:numel(a)
pr = pr + a(k);
end
disp(['total hours of job done by you in a year are: ',num2str(pr)])
if pr >= 2800
disp(['Great...you earned a bonus amount of Rs. ',num2str(bonus)])
else
disp(['better luck next year....'])
end
输出:
a = 12×2
227 183
134 177
28 196
207 72
85 174
74 140
187 100
3 16
13 196
167 85
total hours of job done by you in a year are: 3085
Great...you earned a bonus amount of Rs. 10000