javifelices icon

Ejemplo do while Kodikas

javifelices | PRO | 01/06/19 10:53:18 AM UTC | 0 ⭐ | 251 👁️ | Never ⏰ | []
Java |

780 B

|

None

|

0 👍

/

0 👎

import java.util.Scanner;
 
public class DoWhile {
 
    public static void main(String[] args) {
        
        Scanner teclado = new Scanner(System.in);
        int valor;
        do {
            System.out.print("Ingrese un valor entre 0 y 999 (0 finaliza): ");
            valor = teclado.nextInt();
            if (valor > 999) {
                System.out.println("Tiene más de 3 dígitos");
                System.out.println();
            }
            else if (valor >= 100 && valor <= 999) {
                System.out.println("Tiene 3 dígitos");
                System.out.println();
            }
            else {
                if (valor >= 10) {
                    System.out.println("Tiene 2 dígitos");
                    System.out.println();
                }
                else {
                    System.out.println("Tiene 1 dígito");
                    System.out.println();
                }
            }
            
        } while (valor != 0);
        System.out.println("Fin de CICLO");
 
    }
 
}

Comments