Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void rollTwoDice(){
- Random randomGenerator = new Random();
- System.out.print("Desired sum: ");
- Scanner sc=new Scanner(System.in);
- int sum=sc.nextInt();
- int x = 0;
- int y = 0;
- int expected = 0;
- for (int i = 0; i < 100; i++) {
- x = randomGenerator.nextInt(6);
- y = randomGenerator.nextInt(6);
- expected = x+y;
- System.out.println(x + " and " + y + " = " + expected);
- if(expected == sum) break;
- }
- }
- IS PRIme
- public boolean isPrimeNumber(int n){
- if (n%2==0) return false;
- if (n == 1) return false;
- if (n == -5) return false;
- for(int i=2;i*i<=n;i++) {
- if(n%i==0)
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement