Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SCarroll_assign4_30 {
- public static void main(String[] args) {
- Scanner input = new Scanner( System.in );
- int digits;
- int digits1;
- int digits2;
- int digits3;
- int digits4;
- int digits5;
- System.out.print( "Please enter 5 digits. ");
- digits = input.nextInt();
- digits1 = digits/10000%10;
- digits2 = digits/1000%10;
- digits3 = digits/100%10;
- digits4 = digits/10%10;
- digits5 = digits%10;
- System.out.printf( "The Digits in %d are %d %d %d %d %d.", digits, digits1, digits2, digits3, digits4, digits5);
- //run:
- //Please enter 5 digits. 12345
- //The Digits in 12345 are 1 2 3 4 5.BUILD SUCCESSFUL (total time: 3 seconds)
- //run:
- //Please enter 5 digits. 123456
- //The Digits in 123456 are 2 3 4 5 6.BUILD SUCCESSFUL (total time: 5 seconds)
- //run:
- //Please enter 5 digits. 1234
- //The Digits in 1234 are 0 1 2 3 4.BUILD SUCCESSFUL (total time: 4 seconds)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment