Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package countthedigits;
  7.  
  8. //Imports
  9. import java.util.Scanner;
  10. /**
  11. *
  12. * @author LemoneFresh
  13. */
  14. public class Countthedigits {
  15.  
  16. /**
  17. * @param args the command line arguments
  18. */
  19. public static void main(String[] args) {
  20. // TODO code application logic here
  21.  
  22. //define Variables
  23. final int lowBound = 0,
  24. highBound = 999999999;
  25.  
  26. int userNum = 0,
  27. count = 0;
  28.  
  29. // create a Scanner object to accept keyboard input
  30. Scanner keyboard = new Scanner(System.in);
  31.  
  32. System.out.printf("Please enter a number greater than 0.");
  33. userNum = keyboard.nextInt();
  34.  
  35.  
  36. System.out.println("Number of digits in the entered integer are :: "+count);
  37. }
  38. public static int returnNum(int userNum , int count){
  39. while(userNum!=0){
  40. userNum = userNum/10;
  41. count++;
  42.  
  43. }
  44. return count;
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement