Upload
roy-peralta-barboza
View
1.444
Download
3
Embed Size (px)
DESCRIPTION
Programacion en java sistemas..
Citation preview
PROGRAMACION EN JAVAPROGRAMACION EN JAVA
2DA PARTE
ESTRUCTURAS DE CONTROL: Selectivasl blSimple y Doble
ESTRUCTURAS DE CONTROL: Selectivasl blSimple y Doble
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));BufferedReader br = 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 i á b d d b dsi está aprobado o desaprobado
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)if (nota>=10.5)
System.out.println("Aprobó");elseelse
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úl l ( d d )Múltiples (Anidadas)
ESTRUCTURAS DE CONTROL: Selectivasúl l ( d d )Múltiples (Anidadas)
Ejemplo: Ingresar 3 números enteros i i i di l lpositivos e indicar cual es el mayor
ESTRUCTURAS DE CONTROL: SelectivasESTRUCTURAS DE CONTROL: Selectivasswitch / case:Permite hacer una selección múltiple basado en la condición de i ld digualdad
• Los valores de la variable pueden ser entero oLos 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 labreak, 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 IterativasRepetitivas 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‐SSolución: Diagrama N S
Ejercicio 2
Solución: Diagrama N‐SSolución: Diagrama N S
Ejercicio 3Ejercicio 3
Diagrama N‐SDiagrama N S