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 …

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 pseud…

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 ja…

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 …