Info
This question is closed. Reopen it to edit or answer.
how to make 3 differents inputs with if else statement
3 views (last 30 days)
Show older comments
I want to ake simpel program which has 3 deifferent input. The first thing is you input 3 value of each input, then the results is 3 output with the grade each ouput.
tis the program
Toefl=input('Toefl=')
Math=input('Mathematic=')
Bio=input('Biologi=')
if((Toefl >= 601) && (Toefl <= 670)) && ((Math >= 601) && (Math <= 670)) && ((Bio >= 601) && (Bio <= 670))
disp ('Excellent')
elseif ((Toefl >= 501) && (Toefl <= 600)) && (((Math >= 501) && (Math <= 600)) && ((Bio >= 501) && (Bio <= 600)))
disp ('Good')
elseif ((Toefl >= 401) && (Toefl <= 500)) && (((Math >= 401) && (Math <= 500)) && ((Bio >= 401) && (Bio <= 500)))
disp ('Average')
else (((Toefl <= 400)) && ((Math <= 400)) && ((Bio <= 400)));
disp ('bad')
end
how can i fix it?
the asked result maybe like this
>> Untitled4
Toefl=602
Toefl =
602
Mathematic=502
Math =
502
Biologi=402
Bio =
402
Toefl Excellent
Mathematic Good
Bio Bad
>>
my lecturer said that forbidden to use loops. Thanks
0 Comments
Answers (1)
Raj
on 11 Apr 2019
Edited: madhan ravi
on 11 Apr 2019
Try this:
Toefl=input('Toefl=')
Math=input('Mathematic=')
Bio=input('Biologi=')
if((Toefl >= 601) && (Toefl <= 670)) && ((Math >= 601) && (Math <= 670)) && ((Bio >= 601) && (Bio <= 670))
disp ('Excellent')
elseif ((Toefl >= 501) && (Toefl <= 600)) && (((Math >= 501) && (Math <= 600)) && ((Bio >= 501) && (Bio <= 600)))
disp ('Good')
elseif ((Toefl >= 401) && (Toefl <= 500)) && (((Math >= 401) && (Math <= 500)) && ((Bio >= 401) && (Bio <= 500)))
disp ('Average')
elseif (((Toefl <= 400)) && ((Math <= 400)) && ((Bio <= 400)));
disp ('bad')
else
disp ('Invalid Data')
end
7 Comments
Raj
on 11 Apr 2019
I am not sure what exactly you are looking for. I thought only use of "for" loop is forbidden.
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!