Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class crookedDigits {
- public static void main(String[] args) {
- Scanner user_input = new Scanner(System.in);
- String input = user_input.nextLine();
- long sum = 0;
- input = input.replace(".", "");
- input = input.replace("-", "");
- long number = Long.parseLong(input);
- while (number > 0) {
- sum = sum + number % 10;
- number = number / 10;
- }
- number = sum;
- long n = (long) number;
- while (n != 0) {
- if (sum > 9) {
- sum = 0;
- sum = sum + n % 10;
- n = n / 10;
- sum = n + sum;
- } else {
- System.out.println(sum);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement