Advertisement
joseleonweb

Untitled

Aug 23rd, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ComptaXifres {
  4.   public static void main (String[] args) {
  5.  
  6.     Scanner lector = new Scanner(System.in);
  7.     System.out.print("Quin és el valor per analitzar? ");
  8.     int valor = lector.nextInt();
  9.     lector.nextLine();
  10.     int numXifres = 0;
  11.  
  12.     //"valor" actua com acumulador descendent.
  13.     do {
  14.       valor = valor / 10;
  15.       numXifres++;
  16.     } while(valor != 0);
  17.     System.out.println("El nombre de xifres és " + numXifres + ".");
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement