sábado, 6 de julio de 2013

EJERCICIOS DE REPASO

CONTADOR DE CIFRAS NUMÉRICAS

EJERCICIO  "5"

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import javax.swing.JOptionPane;
public class  Prueba {

   
    public static void main(String[] args) {
        int num;
        boolean estado = true;
        int can_cifra =0;
        num =Integer.parseInt(JOptionPane.showInputDialog("Digite el numero"));
        do{
            if (num==0){
                estado =false;
            } else{
                can_cifra++;
            }
            num=num/10;
        } while (estado==true);
        JOptionPane.showMessageDialog(null,"el numero ingresado tiene: "+ can_cifra + "cifras");
       

    }
}






No hay comentarios:

Publicar un comentario