Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lector_de_digitos;
- import java.util.Scanner;
- public class Lector_de_digitos {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int a;
- do {
- System.out.println("Ingrese un valor entre 0 y 999");
- System.out.println("(Ingrese 0 para finalizar)");
- a = keyboard.nextInt();
- if (a >=1000) {
- System.out.println("El valor ingresado contiene 4 o mas digitos");
- break;
- } else {
- if (a >= 100 && a <=999) {
- System.out.println("Tiene 3 digitos");
- } else {
- if (a >=10 && a <= 99) {
- System.out.println("Tiene 2 digitos");
- } else {
- System.out.println("Tiene 1 digito");
- }
- }
- }
- } while (a != 0 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment