Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
how to make 3 differents inputs with if else statement
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Raj
am 11 Apr. 2019
Bearbeitet: madhan ravi
am 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 Kommentare
Raj
am 11 Apr. 2019
I am not sure what exactly you are looking for. I thought only use of "for" loop is forbidden.
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!