Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.*;
- import java.util.concurrent.ThreadLocalRandom;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Random rand = new Random();
- int[] myList;
- myList = new int[10];
- int[] my2List;
- my2List = new int[10];
- int[] my3List;
- my3List = new int[10];
- System.out.print("First Array: ");
- for (int i = 0; i < myList.length; i++) {
- myList[i] = 1 + rand.nextInt(50);
- System.out.print(myList[i] + " ");
- }
- Scanner keyboard = new Scanner(System.in);
- System.out.println();
- System.out.println("\nValue to find: ");
- int arrayChosen = keyboard.nextInt();
- for (int i = 0; i < myList.length; i++) {
- if (myList[i] == arrayChosen) {
- System.out.println(arrayChosen + " is in the array");
- System.out.print("Second Array: ");
- for (int e = 0; e < my2List.length; e++) {
- my2List[e] = 1 + rand.nextInt(50);
- System.out.print(my2List[e] + " ");
- }
- }
- }
- System.out.println();
- System.out.println("\nValue to find: ");
- int array2Chosen = keyboard.nextInt();
- for (int e = 0; e < myList.length; e++) {
- if (my2List[e] == array2Chosen) {
- System.out.println(array2Chosen + " is in the array");
- }
- }
- System.out.print("Third Array: ");
- for (int y = 0; y < my3List.length; y++) {
- my3List[y] = 1 + rand.nextInt(50);
- System.out.print(my3List[y] + " ");
- }
- System.out.println();
- System.out.println("\nValue to find: ");
- int array3chosen = keyboard.nextInt();
- for (int z = 0; z < my3List.length; z++) {
- if (my3List[z] == array3chosen) {
- System.out.println(array3chosen + " is in the array");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement