Created
January 14, 2013 17:54
-
-
Save annacruz/4531906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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