Pr0gramer

Cantidad de digitos

Aug 2nd, 2018
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package lector_de_digitos;
  2. import java.util.Scanner;
  3. public class Lector_de_digitos {
  4.     public static void main(String[] args) {
  5.     Scanner keyboard = new Scanner(System.in);
  6.     int a;
  7.     do {
  8.         System.out.println("Ingrese un valor entre 0 y 999");
  9.         System.out.println("(Ingrese 0 para finalizar)");
  10.         a = keyboard.nextInt();
  11.         if (a >=1000) {
  12.             System.out.println("El valor ingresado contiene 4 o mas digitos");
  13.             break;
  14.         } else {
  15.             if (a >= 100 && a <=999) {
  16.             System.out.println("Tiene 3 digitos");
  17.             } else {
  18.                 if (a >=10 && a <= 99) {
  19.                     System.out.println("Tiene 2 digitos");
  20.                 } else {
  21.                     System.out.println("Tiene 1 digito");
  22.             }
  23.             }
  24.         }
  25.     } while (a != 0 );
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment