-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2008 from Space9999/Space9999-patch-1
Added a random value generator
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |