How can I intentionally create random floating point / decimal precision errors in java?

My goal is to generate random numbers that all have decimal precision errors. Here are some examples of types of numbers I would like to generate: 1.8181818723678589 1.2727272510528564 0….

Generate a random according to criteria [closed]

I have a JSON File (ArrayList) with some Restaurants and km(miles) from my Workplace to the Restaurant. The User can choose how far away the Restaurant should be (5km, 10km..) after that should the …

After inserting values in JTextField, their random value is not shown. How can I fix it?

I wrote this Java Application which is used to extract a random value from those entered in the JTextFields after starting a counter. Compiles and gives no errors, but the (“” +randomElement)…

Why is my random number generator becoming an unused assignment when using it to input values for 2d array?

I have been making a basic game of battleship and to get the CPU to choose ship locations on a 2d array I am making two random number generators to pick values from 1 to 8 on a separate method. For …

How to get a random multiple of a given number within a range

I’m making a program in which a JPanel is created with a random RGB value and the user has to use buttons to match the color in another JPanel. I want the random R, G, and B values to be multiples of …

Rounding in Java using Math.random()

Suppose I write System.out.println (Math.random()*5); then one would obtain and output of x in [0, 4.9…]. But upon casting it as an integer, the result I continuously see (in my course) is [0, 4]. …

Is there a Java 8 implementation of a random generator supporting NIST standards?

I am trying to securely generate random numbers. It must support NIST standards, that is NIST SP 800-90A, SP 800-90B, SP 800-90C. I’ve read that Java 9 has an implementation of SecureRandom supporting …

Anylogic: Use individual RandomNumberGenerator for each ressource

We are working on a simulation of a production chain of six machines connected in a series. For all of them, we need failure times etc. which are distributed differently. I am looking for a way to …

Can I use a randomly generated number as a parameter to a method in Java?

So I’m very new to Java so this question might have a pretty simple answer. I’m trying to create a Magic8 ball program and I want the fortune to depend on the randomly generated number, but it’s …

Generating Random Number of Characters

I have to create a program that reads in the number of character to be printed, and it will print random chars (a-z, A-Z, 0-9 and characters like !, &, $, etc). And the first character to be …