Introducción a JAVA COMP 250. Estructura de Selección selection statements selection statements – Escoger cuál acción ejecutar dependiendo de dos ó más.

Slides:



Advertisements
Presentaciones similares
11.2 Direct and Inverse Variation
Advertisements

Una estructura de control permite controlar el flujo de la ejecución de instrucciones. Con estas estructuras, el programador puede determinar el orden.
Los Números y El Tiempo. Los Números Más de = once 12 = doce 13 = trece 14 = catorce 15 = quince 16 = dieciseis 17 = diecisiete 18 = dieciocho 19.
FUNDAMENTALS OF THE JAVA PROGRAMMING LANGUAGE (SL-110) CAPÍTULO 5: DECLARACIÓN, INICIALIZACIÓN Y USO DE VARIABLES Ing. Ronald Criollo.
ESTRUCTURAS DE PROGRAMACIÓN
Lenguaje C++.
Telling Time Grammar Essential #8.
11.3 Simplifying Rational Expressions
Beginning Low ESL Teacher
Español 4 Honores. Tema Para el ensayo final, van a escribir sobre una situación hipotética que no es una muy posible. Por eso, no van a usar el presente.
Telling Time in Spanish Grammar Notes
FUNDAMENTALS OF THE JAVA PROGRAMMING LANGUAGE (SL-110) CAPÍTULO 7: OPERADORES Y ESTRUCTURAS DE SELECCION Ing. Ronald Criollo.
EL LENGUAJE DE PROGRAMACIÓN C
1 3 WAYS TO ASK A QUESTION 1.Add question marks to a statement. 2.Add a tag word to a statement. 3.Use a question word.
2003 HYPACK MAX Training Seminar1 Sample Belgium Test Inputting Tag Line information into HYPACK® MAX In the old days, a Tag Line was anchored to.
Copyright © 2008 Vista Higher Learning. All rights reserved Indefinite words refer to people and things that are not specific, for example, someone.
¿Qué hora es? What time is it? (What hour is it?).
Conceptos Básicos del lenguaje de programación COBOL
Introducción a la programación en JAVA
Estructura de Repetición C++
Estructura de Selección en Visual Basic
Telling Time. ¿Qué hora es? What time is it? Es la una. It is one oclock. Son las dos (tres, cuatro…) It is two oclock. Son las dos y cuarto. It is 2:15.
Entrada y salida Fundamentos de programación/Programación I
MATLAB.
` Las Ofrendas. Reason for Creating una Ofrenda 1.To Remember the person who died: How they played an important role in our lives To remember the good.
1 Intersecting chords in the interior of a circle Secants intersecting at a common exterior point. Tangents intersecting at a common exterior point Secant.
PL/SQL Francisco Moreno Universidad Nacional. Funciones Si un procedimiento tiene solo un parámetro de salida, se puede remplazar por una función y esta.
GETTING AROUND TOWN! Estar y Las Direcciones.. El Verbo Estar Use the verb estar to tell the location direction of people and things. For singular places,
Oracle y Java Continuación *
Genéricos en Java Jaime Ramírez, Ángel Lucas González
1.2 Sintaxis del lenguaje Java.
ESTRUCTURAS DE CONTROL
Seminario de Lenguajes A – Opción Ada Seminario de Lenguajes A – Opción Ada – Raúl Champredonde1 Overloading de subprogramas procedure Put(Item: in integer;
Seminario de Lenguajes A – Opción Ada Estructura general de programas –Especificación de contexto –Encabezado –Declaraciones –Cuerpo Seminario de Lenguajes.
Seminario de Lenguajes A – Opción Ada
Ocurre con frecuencia, tanto en programación como en la vida real, que las decisiones que se nos pide tomar son más complicadas que una simple selección.
ESTRUCTURAS DE SECUENCIA
Articles, nouns and contractions oh my!. The POWER of the article THE 1. There are four ways to express THE in Spanish 2. The four ways are: El La Los.
ESTRUCTURAS DE CONTROL SELECTIVA LUIS OCTAVIO BUSTAMANTE Docente Colegio de la UPB.
Adivina quién soy Una autobiografía breve. Purpose Use what you know from Spanish 1 to describe yourself Trade and then read aloud to guess who the person.
¿Qué hora es? Avancemos U2L1 La hora. On the hour… en punto Es la una. ◦It’s 1:00  Use es la only for the one hour (it is singular) Son las dos. ◦???
Diseño Estructurado de Programas – Parte I Preparado por la Prof. Lillian Bras con la colaboración del Prof. Antonio F. Huertas COTI 3101 – Algoritmos.
Repaso (parte 2) Español 2. Como escribir una pregunta…  Adónde (to where)  Cómo (how)  Cuál/Cuáles (which ones)  Cuándo (when)  Cuánto (how much)
Quantity How much? How many?
Los números Mathematical problem solving Existence/Non-existence Quantity How much? How many?
Lenguajes de Programación Tema 4. Paradigma Orientado a Objetos Java 1.5 Pedro García López
Estructuras de Control
If anidados y Switch Prof. Lillian Bras.
Sección 5-2 Estructuras de Control de Decisión Expresiones Lógicas.
El lenguaje de programación Java
JAVA J.A.C..
Numeric Types, Expressions, and Output
Java. Java nació el año 1991, por un par de ingenieros de la Sun Microsystems.
Pulse para añadir texto Desarrollo de sitios web con PHP y MySQL Tema 2: Lenguaje PHP básico Elaborado por: José Mariano González Romano
Prof. Mayra M. Méndez Anota.  Herramientas  Características  Convenciones  Estructura de una clase  Sintaxis de: métodos, atributos, constructores.
UNIVERSIDAD PERUANA DE LAS AMERICAS INGENIERIA DE COMPUTACION Y SISTEMAS PROGRAMACION I ING. PEDRO BENITES TOLEDO Programación I Capitulo IV : Estructuras.
Estructura de Selección en JAVA
En El Hotel. Buenos días ¿ En qué puedo ayudarle?
Lógica de Programación COIS 115 Profesor: Gustavo Velez.
HOW LONG AGO: HACER WITH EXPRESSIONS OF TIME. Para el fin de esta leccíon, se puede:  Comprender los usos de “hacer” con expresiónes de tiempo.  Comprender.
2012-BM5A. Unos tips antes de empezar: C# es Case Sensitive (sensible a mayúsculas) Pepe ≠ pepe ≠ pEpE Las asignaciones se hacen con “=” y las comparaciones.
Estructuras de control Por Diego Caro A. udec.cl}
Control, adquisición y monitoreo con Arduino y Visual Basic .net
Introducción a JAVA COMP 250.
Conceptos Básicos Prof. Carlos Rodríguez Sánchez
¿Cómo almacenar datos dentro del computador?
Teclado y Pantalla (Java estándar)
Programación en Java..
Leyendo strings de la línea de comandos
Astronomy has really big numbers. Distance between Earth and Sun meters kilometers This is the closest star.
Transcripción de la presentación:

Introducción a JAVA COMP 250

Estructura de Selección selection statements selection statements – Escoger cuál acción ejecutar dependiendo de dos ó más alternativas a evaluar booleanas booelano – Las condiciones son expresiones booleanas, esto es, el resultado de una comparación es un valor booelano (true / false)

Estructura de Selección Operadores de comparación operadornombreejemploresultado <Menor queRadius < 0false <=Menor o igual a Radius <= 0false >Mayor queRadius > 0true >=Mayor o igual a Radius >= 0true ==Igual aRadius == 0false !=No igual aRadius != 0true Observar que el radio de un círculo no puede ser cero ó negativo (menor que cero)

Estructura de Selección Ejemplo double radius = 1; System.out.println(radius > 0); – El valor a mostrar en el output debe ser true

Estructura de Selección if statements – One-way if statements Formato: if (boolean-expression) { statement(s); } (radius >= 0) false true area = radius * radius * PI; System.out.println(The area for the circle of radius + radius + is + area);

Estructura de Selección Two-way if statement – Formato: if(boolean-expression) { statement(s)-for-the-true-case; } else { statement(s)-for-the-false-case; } Boolean expression falsetrue Statements for the true case Statements for the false case

Estructura de Selección Nested if statements if (score >= 90.0) grade = A; else if (score >= 80.0) grade = B; else if (score >=70.0) grade = C; else if (score >= 60.0) grade = D; else grade = F;

Estructura de Selección switch statement status = 0 Compute tax for single filers break Status = 1 Compute tax for married filers break Default actions default T T F

Estructura de Selección Ejemplo: switch (status) { case 0: compute taxes for single filers; break; case 1: compute taxes for married filers; break; default: System.out.println(Errors: invalid status); System.exit(0);

Formatting console output Formato general: System.out.printf(format, item1, item2, …itemz) Donde format es un string que puede consistir de varios formatos especializados

Formatting console output specifieroutputexample %bA boolean valueTrue or false %cA charactera %dA decimal integer200 %fA floating-point number %eA number in standard scientific notation e+01 %sA stringJava is cool Ejemplo: int count =5; double amount = 45.56; System.out.printf(count is %d and amount is %f, count, amount); Output: count is 5 and amount is

Formatting console output exampleoutput %5cOutput the character and add four spaces before the character item %6bOutput the boolean value and add one space before the false value and two spaces before the true value %5dOutput the integer with width at least 5. %10.2fOutput the floating-point number with width at least 10 including a decimal point and two digits after the point. %10.2eOutput the floating-point item with width at least 10 including a decimal point, two digits after the point and the exponent part. %12sOutput the string with width at least 12 characters

Logical Operators operatornamedescription !notLogical negation &&andLogical conjunction ||orLogical disjunction ^Exclusive orLogical exclusion Ejemplos: (asumir que age = 24, gender = F) !(age > 18) …………………………………………………..false !(gender == M)…………………………………………..true