UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 10 de junio de 2015

PROBLEMA 45

45.- DADO UN NÚMERO DETERMINAR CUÁNTOS DÍGITOS TIENE.



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema45dadounnumerodeterminarcuantosdigitostiene;
import java.util.Scanner;
/**
 *

 */
public class Problema45dadounnumerodeterminarcuantosdigitostiene {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       int n,c=0;
       Scanner teclado=new Scanner(System.in);
       System.out.println("Número: " );
       n=teclado.nextInt();
       
       while (n>0)
       {
       n=n/10;
       c+=1;
       }
       System.out.println(" " );
       System.out.println("Cantidad de Dígitos: "+c);

    }
}

No hay comentarios:

Publicar un comentario