Question
USING JAVA Task : Try different values of a, b, and m to get your random number generator method to produce at least 6 values.
USING JAVA
Task: Try different values of a, b, and m to get your random number generator method to produce at least 6 values. Hint: think about how the mod operation works; larger values of m may be to your benefit. When you have accomplished this task, your test will pass.
public class Main {
public static int random(int n)
{
int Rn = 0;
int n1, n2;
final int a=5, b=7, m=12;
for (int i=0; i
n1 = Rn * a;
n2 = n1 + b;
Rn = n2 % m;
}
return Rn;
}
public static void main(String [] args)
{
System.out.println("The 10th random number is " + random(10));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Elements Of Chemical Reaction Engineering
Authors: H. Fogler
6th Edition
013548622X, 978-0135486221
Students also viewed these Databases questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App