Advertisement
RazorBlade57

Digit adder

Nov 30th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DigitCount {
  4.  
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner keyboard = new Scanner(System.in);
  8.         System.out.println("Please enter an integer ::");
  9.         int a = keyboard.nextInt();
  10.         int count = 0;
  11.        
  12.         while (a > 0){
  13.             a = a % 10;
  14.             count++;
  15.             int sum = a + count++;
  16.            
  17.         }
  18.         System.out.println(count);
  19.  
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement