Skip to content

Instantly share code, notes, and snippets.

@annacruz
Created January 14, 2013 17:54
Show Gist options
  • Save annacruz/4531906 to your computer and use it in GitHub Desktop.
Save annacruz/4531906 to your computer and use it in GitHub Desktop.
import javax.swing.JOptionPane;
public class MaiorMenor {
public static void main(String[] args) {
String argumento;
int maior = 0;
int menor = Integer.MAX_VALUE;
argumento = JOptionPane.showInputDialog("Insira um número");
while (!"FIM".equalsIgnoreCase(argumento)) {
int num = Integer.parseInt(argumento);
if (argumento.equalsIgnoreCase("FIM")) {
break;
}
if (num > maior) {
maior = num;
}
if (num < menor) {
menor = num;
}
argumento = JOptionPane.showInputDialog("Insira um número");
}
JOptionPane.showMessageDialog(null, "Maior: " + maior + " || Menor: " + menor);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment