Advertisement
javifelices

Ejemplo do while Kodikas

Jan 6th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DoWhile {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner teclado = new Scanner(System.in);
  8.         int valor;
  9.         do {
  10.             System.out.print("Ingrese un valor entre 0 y 999 (0 finaliza): ");
  11.             valor = teclado.nextInt();
  12.             if (valor > 999) {
  13.                 System.out.println("Tiene más de 3 dígitos");
  14.                 System.out.println();
  15.             }
  16.             else if (valor >= 100 && valor <= 999) {
  17.                 System.out.println("Tiene 3 dígitos");
  18.                 System.out.println();
  19.             }
  20.             else {
  21.                 if (valor >= 10) {
  22.                     System.out.println("Tiene 2 dígitos");
  23.                     System.out.println();
  24.                 }
  25.                 else {
  26.                     System.out.println("Tiene 1 dígito");
  27.                     System.out.println();
  28.                 }
  29.             }
  30.            
  31.         } while (valor != 0);
  32.         System.out.println("Fin de CICLO");
  33.  
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement