Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/** * The pseudorandom Java application produce random number anddecimal values

ID: 3607993 • Letter: #

Question

/**
* The pseudorandom Java application produce random number anddecimal values and prints a
* table of how decimal values locate in the range of[0..1)
* @author Henry Wang (natural26@hotmail.com)
*
*/
public class pseudorandom {

double random;
double seed, multiplier, increment, modulus;

/**
* Initialize the seed, multiplier, increment, and modulusvalues as a constructor
*/
public pseudorandom(){
  seed = 1;
  multiplier = 40;
  increment = 3641;
  modulus = 729;
}
/**
* The generate method can use the seed, multiplier,increment, and modulus which
* initialized in the constructor to generate a pseudorandomrandom number by formula
* ((seed*multiplier)+increment)%modulus
* @return pseudorandom random number
*/
public double generate(){
  random = ((seed*multiplier)+increment)%modulus;
  return random;
}

/**
* Changeseed method is designed to replace the former seedby the pseudorandom random number
* to produce a new random value
*/
public void changeseed(){
  seed = ((seed*multiplier)+increment)%modulus;
}


/**
* decimalrandom method use the pseudorandom random numberdevide by modulus to generate
* a random decimal value in the range of [0..1)
* @return pseudorandom random decimal value
*/
public double decimalrandom(){
  double g;
  g = ((seed*multiplier)+increment)%modulus;
  random = g/modulus;
  return random;
}

public voiddisplay(){
  System.out.println(random + "," + seed + "," +multiplier + "," + increment + "," + modulus);

}

/**
* The main method application is designed to run thedecimalrandom method and create
* a table to gather stastistic of the random decimal values.Set i as a looping variable
* to run the method a million times. In the loop, first,generate a pseudorandom random
* number. Second, replace the seed by the random number.Then, replace the random number
* by random decimal value. Use a bunch of if to count therandom decimal results. After
* the loop, print out the table.
*
* @param args
*/

public static void main(String[] args) {
  pseudorandom henry = new pseudorandom();
  int first=0, second=0, third=0, fourth=0, sixth=0,fifth=0,
      seventh=0, eighth=0, nineth=0,tenth=0;
  for(int i=0; i<1000000; i++){
  henry.generate();
  henry.changeseed();
  henry.decimalrandom();
  if (henry.random>=0 && henry.random<=0.1)first++;
  if (henry.random>=0.1 &&henry.random<=0.2) second++;
  if (henry.random>=0.2 &&henry.random<=0.3) third++;
  if (henry.random>=0.3 &&henry.random<=0.4) fourth++;
  if (henry.random>=0.4 &&henry.random<=0.5) fifth++;
  if (henry.random>=0.5 &&henry.random<=0.6) sixth++;
  if (henry.random>=0.6 &&henry.random<=0.7) seventh++;
  if (henry.random>=0.7 &&henry.random<=0.8) eighth++;
  if (henry.random>=0.8 &&henry.random<=0.9) nineth++;
  if (henry.random>=0.9 &&henry.random<=1.0) tenth++;
  }
  
  System.out.println("[0.0..0.1)           " + first);
  System.out.println("[0.1..0.2)           " + second);
  System.out.println("[0.2..0.3)           " + third);
  System.out.println("[0.3..0.4)           " + fourth);
  System.out.println("[0.4..0.5)           " + fifth);
  System.out.println("[0.5..0.6)           " + sixth);
  System.out.println("[0.6..0.7)           " + seventh);
  System.out.println("[0.7..0.8)           " + eighth);
  System.out.println("[0.8..0.9)           " + nineth);
  System.out.println("[0.9..1.0)           " + tenth);
}

}

My question is how to impletment a JAVA applet to printthe same table as I had in this application.

Explanation / Answer

/** * The pseudorandom Java application produce random number anddecimal values