¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 7 de 18 · Multimedia

Nested if statements

Kostas Diakogiannis

Nested if statements

Nested if statements

 

What if i want to check further conditions inside conditions?

For example i want to check for a condition if the weather is bad. In case this is false i decide to go out with my t-shirt.

What if this is true? Then i need to check further if we are talking about rain (so i would take an umbrella, or if it snows , then i will go skiing!).

It is also possible to implement if statements that are lying inside other if statements. As the picture shows above, first i check if i have enough money to buy a single room to spend the night. If this is true, then and ONLY then i can explore further and check if i have 100$ more than the cheapest room. In such case, i can go possibly to a better hotel, or for example upgrade for a better room. If not, then probably i will take the cheapest room. 

All this upgrade plan will happen ONLY if i have enough money to take the cheapest room, then i can ask further to make myself more comfortable etc. But if i don't have the money even for that, then i will have to keep looking elsewhere. 

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?