Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
how to make 3 differents inputs with if else statement
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Raj
el 11 de Abr. de 2019
Editada: madhan ravi
el 11 de Abr. de 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 comentarios
Raj
el 11 de Abr. de 2019
I am not sure what exactly you are looking for. I thought only use of "for" loop is forbidden.
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!