-4

like this :

Sample run:
Please enter a number: 1234567
The shuffled number is: 4356271
Sample run:
Please enter a number: 1000001
The shuffled number is: 0100100

mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • 2
    Welcome to Stack Overflow! Please visit the [help], take the [tour] to see what and [ask]. Do some research, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output. – mplungjan Mar 13 '18 at 16:06
  • While I agree with the close, I disagree with the duplicate question. – AntonH Mar 13 '18 at 16:08
  • @AntonH See the list of dupes now. I can add JavaScript if needed – mplungjan Mar 13 '18 at 16:31

1 Answers1

-1

Converting the number in a String use this method passing the string to it!

public void shuffle(String input){
        List<Character> characters = new ArrayList<Character>();
        for(char c:input.toCharArray()){
            characters.add(c);
        }
        StringBuilder output = new StringBuilder(input.length());
        while(characters.size()!=0){
            int randPicker = (int)(Math.random()*characters.size());
            output.append(characters.remove(randPicker));
        }
        System.out.println(output.toString());
    }
SmoggeR_js
  • 2,950
  • 4
  • 22
  • 52