Last active
August 29, 2015 14:13
-
-
Save JuanjoSalvador/a26f00fcc656dc911d72 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
// Programa para separar los digitos de un número dado | |
import java.util.Scanner; | |
public class Separador { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
int numero, d1, d2, d3, d4, d5; | |
System.out.println("Ingrese un número de 5 dígitos: "); | |
numero = input.nextInt(); | |
d1 = numero % 10; | |
d2 = numero % 100 / 10; | |
d3 = numero % 1000 / 100; | |
d4 = numero % 10000 / 1000; | |
d5 = numero % 100000 / 10000; | |
System.out.println("El número ingresado está compuesto por los siguiente dígitos: "); | |
System.out.printf("%d %d %d %d %d\n\n", d5, d4, d3, d2, d1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment