witchway915

Untitled

Sep 1st, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SCarroll_assign4_30 {
  4.  
  5.  
  6. public static void main(String[] args) {
  7.  
  8. Scanner input = new Scanner( System.in );
  9.  
  10. int digits;
  11. int digits1;
  12. int digits2;
  13. int digits3;
  14. int digits4;
  15. int digits5;
  16.  
  17. System.out.print( "Please enter 5 digits. ");
  18. digits = input.nextInt();
  19.  
  20. digits1 = digits/10000%10;
  21. digits2 = digits/1000%10;
  22. digits3 = digits/100%10;
  23. digits4 = digits/10%10;
  24. digits5 = digits%10;
  25.  
  26. System.out.printf( "The Digits in %d are %d %d %d %d %d.", digits, digits1, digits2, digits3, digits4, digits5);
  27.  
  28. //run:
  29. //Please enter 5 digits. 12345
  30. //The Digits in 12345 are 1 2 3 4 5.BUILD SUCCESSFUL (total time: 3 seconds)
  31.  
  32. //run:
  33. //Please enter 5 digits. 123456
  34. //The Digits in 123456 are 2 3 4 5 6.BUILD SUCCESSFUL (total time: 5 seconds)
  35.  
  36. //run:
  37. //Please enter 5 digits. 1234
  38. //The Digits in 1234 are 0 1 2 3 4.BUILD SUCCESSFUL (total time: 4 seconds)
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment