# Thread: How to write a JAVA program that reads a whole number and tells you the decimal place

1. Member Join Date
Oct 2014
Posts
9
Rep Power
0

## How to write a JAVA program that reads a whole number and tells you the decimal place

Ex. If I type 5943, the program will say

mill = 5

hun = 9

ten = 4

uni = 3

I hope you get the picture I had to translate the decimal value names from a different language.

This is what I have tried...,
Java Code:
```import java.util.Scanner;//Permite el uso de leer el teclado del usuario

public class DeterminarValorDecimal//Nombra el documento
{

public static void main(String [] args)//Podemos ver la clase
{

Scanner input = new Scanner( System.in );//Provee la herramienta para leer el teclado de el usuario

int nument1,//Declaracion de variable
nument2,
nument3,
nument4;

System.out.print( "Entre un numero de el 0 al 9 " );
nument1 = input.nextInt();
System.out.print( "Entre un numero de el 0 al 9 " );
nument2 = input.nextInt();
System.out.print( "Entre un numero de el 0 al 9 " );
nument3 = input.nextInt();
System.out.print( "Entre un numero de el 0 al 9 " );
nument4 = input.nextInt();
System.out.println(nument1 + " Millares " + nument2 + " Centenas " + nument3 + " Decenas " + nument4 + " Unidades ");
}=
}```
But what this does is I have to enter the single digits one by one. I want to be able to type the whole number. Is there a method that reads the length of the whole number and lets me classify each digit so I can do what I want to do?
Last edited by xlactyu; 10-10-2014 at 06:41 PM.  Reply With Quote

2. ## Re: How to write a JAVA program that reads a whole number and tells you the decimal p

If you read the number as a String, the String class has methods you can use to get the single digits in the String.  Reply With Quote