PROGRAMACION EN JAVA
PROGRAMACION EN JAVA

      2DA PARTE
ESTRUCTURAS DE CONTROL: Selectivas
         Simple y Doble
             l      bl
ESTRUCTURAS DE CONTROL: Selectivas
         Simple y Doble
             l      bl
Ejemplo1:Leer un número e indicar si 
                    es positivo
import java.io.*;
public class EjercicioCon1 {
  public static void main(String[] args)throws IOException {
         BufferedReader br = new BufferedReader (new InputStreamReader (System in));
                           = new BufferedReader (new InputStreamReader (System.in));
         byte n;
         System.out.println("Ingrese un numero entero: ");
         n=Byte.parseByte(br.readLine());
         if (n>0)
         System.out.println( Numero Positivo );
         System.out.println("Numero Positivo");
    }
}
Ejemplo2: Leer la nota de un alumno y reportar 
           si está aprobado o desaprobado
            i á        b d    d      b d
import java.io.*;
  p j            ;
public class EjercicioCon2 {
  public static void main(String[] args) throws IOException {
  BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
  float nota;
  System.out.println("Ingrese nota: ");
                    (                )
  nota=Float.parseFloat(br.readLine());
  if (nota>=10 5)
     (nota>=10.5)
       System.out.println("Aprobó");
  else
       System.out.println("Desaprobó");
  }
Ejemplo 3: Una llamada telefónica en cualquier en cualquier teléfono 
público cuesta S/. 0.50 por los primeros 3 minutos o menos. Cada minuto 
p                       p       p
   adicional cuesta S/. 0.10. Calcule el costo de una llamada cualquiera
ESTRUCTURAS DE CONTROL: Selectivas
       Múltiples (Anidadas)
         úl l ( d d )
ESTRUCTURAS DE CONTROL: Selectivas
       Múltiples (Anidadas)
         úl l ( d d )
Ejemplo: Ingresar 3 números enteros 
 positivos e indicar cual es el mayor
    ii       i di       l     l
ESTRUCTURAS DE CONTROL: Selectivas
ESTRUCTURAS DE CONTROL: Selectivas
switch / case:
Permite hacer una selección múltiple basado en la condición de 
igualdad
i ld d
• Los valores de la variable pueden ser entero o
  Los valores de la variable pueden ser entero o 
  carácter.
  – default significa si no es ninguno de los valores
    default, significa si no es ninguno de los valores 
    anteriores (o en caso contrario)
  – break significa interrumpir y abandonar la
    break, significa interrumpir y abandonar la 
    instrucción switch / case (y continuar con lo que 
    sigue)
Ejemplo: Dado un numero, determinar el mes
ESTRUCTURAS DE CONTROL: Repetitivas 
           o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
ESTRUCTURAS DE CONTROL: 
   Repetitivas o Iterativas
Ejemplo 1:
 j p
Solución: Diagrama N S
Solución: Diagrama N‐S
Ejercicio 2
Solución: Diagrama N S
Solución: Diagrama N‐S
Ejercicio 3
Ejercicio 3
Diagrama N S
Diagrama N‐S

Programacion en java