-
Notifications
You must be signed in to change notification settings - Fork 0
/
If-Else.m
55 lines (30 loc) · 1.09 KB
/
If-Else.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%Take input for maths, physics and chemistry score
maths = input("Enter the maths score: ");
physics = input("Enter the physics score: ");
chemistry = input("Enter the chemistry score: ");
%check whether the input is valid score or not
if((maths>=0 && maths<=100)&&(physics>=0 && physics<=100)&&(chemistry>=0 && chemistry<=100))
%eligible will be 1 if the candidate is eligible else zero
eligible = admission(maths, physics, chemistry);
else
% if the score is invalid display invalid input
disp("Invalid Input");
end
%function to calculate the eligibility of the a student
function eligible = admission(maths, physics, chemistry)
if(maths<0 || maths >100 || physics<0 ||physics>100 || chemistry<0 || chemistry>100)
disp("Invalid Input!!")
else
m = maths >= 65;
p = physics >= 55;
c = chemistry >= 50;
total = ((maths+physics+chemistry) >= 190) | (maths+physics >= 130);
if(m && p && c && total)
disp("The candidate is eligible for admission");
eligible = 1;
else
disp("The candidate is not eligible for admission");
eligible = 0;
end
end
end