reformating of the code and added import of java.util.Random