Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ComptaXifres {
- public static void main (String[] args) {
- Scanner lector = new Scanner(System.in);
- System.out.print("Quin és el valor per analitzar? ");
- int valor = lector.nextInt();
- lector.nextLine();
- int numXifres = 0;
- //"valor" actua com acumulador descendent.
- do {
- valor = valor / 10;
- numXifres++;
- } while(valor != 0);
- System.out.println("El nombre de xifres és " + numXifres + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement