Академический Документы
Профессиональный Документы
Культура Документы
Virtu@l
Estructuras
Selectivas:
switch - case
NDICE
1. Introduccin ................................................................................ 3
2. Objetivos ..................................................................................... 3
3. Estructuras de Condicionales ...................................................... 3
3.1. Decisin o Alternativa Mltiple...................................... 3
3.2. Switch.............................................................................. 4
4. Ejemplos...................................................................................... 5
5. Glosario ....................................................................................... 7
6. Referencias Bibliogrficas .......................................................... 7
Pgina 2
Estructuras Selectivas: switch - case Tecsup
Agosto 2008
1. Introduccin
2. Objetivos
3. Estructuras de Condicionales
Actividad:
Qu son las Estructuras de Switch - Case?
Dar dos ejemplos
Pgina 3
Tecsup Estructuras Selectivas: switch - case
Agosto 2008
3.2. Switch
switch(patron) {
case 1: sentencias(s); break;
case 2: sentencias(s); break;
default : sentencias(s);
}
Switch:
switch( expresin ) {
case valor1:
sentencias;
break;
case valor2:
sentencias;
break;
}
Pgina 4
Estructuras Selectivas: switch - case Tecsup
Agosto 2008
4. Ejemplos
// Estaciones.java
switch (num) {
case 1:
System.out.println("Verano"); break;
case 2:
System.out.println("Otono"); break;
case 3:
System.out.println("Invierno"); break;
case 4:
System.out.println("Primavera"); break;
}
}
}
// Menu.java
return opcion;
}
Pgina 5
Tecsup Estructuras Selectivas: switch - case
Agosto 2008
}
public int Restar(int valor1, int valor2){
return (valor1 - valor2);
}
public static int Multiplicar(int valor1, int
valor2){
return (valor1 * valor2);
}
Pgina 6
Estructuras Selectivas: switch - case Tecsup
Agosto 2008
Resultado:
5. Glosario
6. Referencias Bibliogrficas
Pgina 7
Tecsup Estructuras Selectivas: switch - case
Agosto 2008
http://www.desarrolloweb.com/articulos/169.php?manual=1
http://laurel.datsi.fi.upm.es/~rpons/personal/trabajos/curs
o_c/node63.html
FIN DE LA UNIDAD
Pgina 8