SHARE
TWEET

Untitled

joseleonweb Aug 23rd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top