Advertisement
dicmri

Untitled

Nov 1st, 2024 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class DigitBreaker {
  3.     public static void main(String[] args) {
  4.         Scanner x = new Scanner(System.in);
  5.         System.out.print("input digits: ");
  6.         int num = x.nextInt();
  7.         int num2 = num;
  8.         int i = 0;
  9.         int j = 1;
  10.         int k = 1;
  11.         while(num2 !=0)
  12.         {
  13.             num2/=10;    
  14.             i++;
  15.         }
  16.         while(k < i)
  17.         {
  18.             j*=10;
  19.             k++;
  20.         }
  21.         System.out.print(j + " value of j ");
  22.         System.out.print("Expected Output: ");
  23.         while(num != 0 && j !=0)
  24.         {
  25.             System.out.print(num/j + "  ");
  26.             num = num%10;
  27.             j/=10;
  28.         }
  29.        x.close();
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement