programación i - Universidad ORT Uruguay
programación i - Universidad ORT Uruguay
programación i - Universidad ORT Uruguay
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Programación I 41<br />
Operador Descripción<br />
< Menor que<br />
> Mayor que<br />
= Mayor o igual que<br />
== Igual<br />
!= Distinto<br />
Como se observa en la tabla anterior, el símbolo == corresponde al operador de comparación<br />
por igualdad. Es diferente a =, que representa una asignación.<br />
3.5.8 Codificación del máximo<br />
La codificación de este programa es:<br />
import java.util.*;<br />
public class Prueba{<br />
public static void main (String args[]){<br />
int max = Integer.MIN_VALUE; // es el Low Value<br />
int dato;<br />
boolean hubo = false;<br />
String resp;<br />
Scanner input = new Scanner(System.in);<br />
input.useDelimiter(System.getProperty("line.separator"));<br />
}<br />
}<br />
System.out.println("Quiere ingresar algo?");<br />
resp = input.next();<br />
while (resp.equals("S")){<br />
hubo = true;<br />
System.out.println("Ingrese dato");<br />
dato = input.nextInt();<br />
if (dato > max){<br />
max = dato;<br />
}<br />
System.out.println("Mas datos?");<br />
resp = input.next();<br />
}<br />
if (hubo){<br />
System.out.println("Máximo vale "+max);<br />
}<br />
else {<br />
System.out.println("No hubo datos");<br />
}<br />
input.close();<br />
Notar la correspondencia prácticamente línea a línea del seudocódigo al código. Para preguntar<br />
si un String es igual a otro se utiliza equals, se verá detalladamente más adelante.