Advertisement
xerxeslins

Separdor de algarismos

Jan 25th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class Exercicio {
  4.  
  5.    public static void main (String args[]) {
  6.  
  7.       String   numeroDeCincoAlgarismos;
  8.      
  9.       int   numeroInteiro,
  10.          primeiroAlgarismo,
  11.          segundoAlgarismo,
  12.          terceiroAlgarismo,
  13.          quartoAlgarismo,
  14.          quintoAlgarismo;
  15.    
  16.       numeroDeCincoAlgarismos = JOptionPane.showInputDialog("Digite um número de cinco algarismos:");
  17.       numeroInteiro = Integer.parseInt (numeroDeCincoAlgarismos);
  18.  
  19.       primeiroAlgarismo = (numeroInteiro / 10000);
  20.       segundoAlgarismo = ((numeroInteiro / 1000) % 10);
  21.       terceiroAlgarismo = ((numeroInteiro / 100) % 10);
  22.       quartoAlgarismo = ((numeroInteiro / 10) % 10);
  23.       quintoAlgarismo = (numeroInteiro % 10);
  24.  
  25.       JOptionPane.showMessageDialog (null,
  26.          primeiroAlgarismo + "   " +
  27.          segundoAlgarismo + "   " +
  28.          terceiroAlgarismo + "   " +
  29.          quartoAlgarismo + "   " +
  30.          quintoAlgarismo
  31.       );
  32.  
  33.       System.exit(0);
  34.  
  35.    }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement