• Lenguaje

    Java usando Scanner

  • Descripción

    Determine la cifra de las unidades de un número natural

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.util.Scanner;

public class UnidadesDeUnNumeroNatural {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double cifras, numero;
        System.out.print("Ingresa el valor de numero: ");
        numero = in.nextDouble();
        in.nextLine();
        cifras=Math.floor(Math.log(numero)/Math.log(10))+1;
        System.out.println("Valor de cifras: " + cifras);
    }

}