Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a random value generator #2008

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions js/GeneratesRandomValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;

// Generates a random value and prints it
public class GeneratesRandomValue {
public static void main(String[] args) {
Random random = new Random();
int number1 = random.nextInt(100000);
int randomnumber = encryption(number1);
System.out.println(randomnumber);
}
public static int encryption(int num) {
Random random = new Random();
int x = random.nextInt(10057003);
int y = random.nextInt(10037262);
if (num % 2 == 0) {
num /= 8;
num = num + num * (x / 2);
}
else {
num /= 86;
num = num + num * (y / 5);
}
return num;
}
}