Skip to content

Tag: random

Shuffle a string via swapping content to different index

I have an assignment in which we are instructed to create a method which takes a string, scrambles the content of the string, and then returns the scrambled string (ie “Hello” returns “elloH”). However, we are only allowed to do this via loops and basic string functions (no arrays can be used). My Teacher has left the following suggestion for

Are there any java.util.random seeds with bad/weird properties? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 months ago. Improve this question I’m curious if there are seeds for java.util.random which have weird/surprising properties. This has little practical use, but I’m still curious. edit: by weird/surprising properties

Drawing raffle numbers out of list that can have duplicates in Java

I was trying to learn programming by writing code with friends, we are all new though and are stuck with this raffle program. Players can earn multiple raffle tickets. The raffle tickets are written down in a new row in an ArrayList when they are earned. It looks like this: “PlayerA PlayerB PlayerB PlayerC PlayerD PlayerE PlayerF” Now we want

What is the distribution of math.random in Java?

I want to use math.random() in a Java program. What is the distribution of this way of getting doubles? Answer This is documented in the Java SE API docs: public static double random() Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution

How to get java to recognize a certain group of random integers

It’s slightly hard to explain but I’m making a basic system were it would have a random chance to output something else, I have a single integer that can be different, and need java to be able to know when this said integer is going to be 580-599. I’m Completely stuck and I’m new to java. (I’m not sure if

How can I create an Array in Descending Order?

I’m working on this project using Arrays. I have a method called createRandomIntArray that creates an array. This method is meant to return the Array in descending order. I have been able to do just that but I want to know if there is a more effective way to write this method than the way I wrote it. I have