In java:
write a lottery program that picks 4 random numbers between 1-9 and print the number. If the number is a duplicate, then run it again until there are no duplicates.
import java.util.Random;
public class Lottery {
public static void main(String[] args) {
Random random = new Random();
int arr[] = new int[4];
int k = 0, num, j;
for(int i = 0;i<4;){
num = random.nextInt(9)+1;
for(j = 0;j<k;j++){
if(num == arr[j]){
break;
}
}
if(j == k){
arr[k++] = num;
i++;
}
}
for(int i = 0;i<4;i++){
System.out.println(arr[i]);
}
}
}

In java: write a lottery program that picks 4 random numbers between 1-9 and print the...