Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class template {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. int opcao = 1;
  8.  
  9. while(opcao > 0 && opcao < 3) {
  10.  
  11. opcao = Integer.parseInt(JOptionPane.showInputDialog("1 - Mostrar nome\n"
  12. + "2 - Solicitar numero e mostrar se é par\n"
  13. + "3 - Sair"));
  14.  
  15. switch(opcao) {
  16. case 1:
  17. JOptionPane.showMessageDialog(null, "Daniel e Matheus");
  18. break;
  19.  
  20. case 2:
  21. int numero = Integer.parseInt(JOptionPane.showInputDialog("Digite um numero"));
  22.  
  23. if(numero%2 == 0) {
  24. JOptionPane.showMessageDialog(null, "O numero é par");
  25. }
  26. else{
  27. JOptionPane.showMessageDialog(null, "O numero é impar");
  28. }
  29. break;
  30. }
  31.  
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement