Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Rand {
- int[] rad;
- int[] random_rand() {
- int Rand[]=new int[7];
- int i=0,j=0;
- boolean Same=false;
- //Get 7 random numbers
- System.out.println("\n7 random numbers:");
- for(i=0;i<7;i++) {
- Random rand = new Random();
- Rand[i]=rand.nextInt(39);
- System.out.print(Rand[i]+" ");
- }
- // continues on the other side
- //Check if they are different from eachother
- for(i=0;i<7;i++) {
- for(j=0;j<i;j++) {
- do{
- if(Rand[i]==Rand[j]){
- Random rand = new Random();
- Rand[i]=rand.nextInt(39);
- Same=true;
- }
- else{Same=false;}
- }
- while(Same==true);
- }
- }
- return Rand;
- }
- }
- ______________________________________________________________________________________
- import java.util.Scanner;
- public class battreanjonis {
- static Scanner scn = new Scanner(System.in);
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Rand r = new Rand();
- r.random_rand();
- r.random_rand();
- r.random_rand();
- r.random_rand();
- while(jonej()){
- Rand r1 = new Rand();
- r1.random_rand();
- }
- }
- static boolean jonej(){
- System.out.println("Spela lotto? 1/0");
- if(scn.nextInt()==1){
- return true;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment