Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Main {
- public static void main(String[] args) {
- Random rand = new Random();
- Scanner scan = new Scanner(System.in);
- int[] num = new int[10];
- System.out.print("Array 1: ");
- for( int x = 0; x < num.length; x++){
- num[x] = rand.nextInt(100)+1;
- System.out.print( num[x] + " ");
- }
- System.out.print("\nValue to find: ");
- int value = scan.nextInt();
- for (int x: num){
- if( x == value){
- System.out.println(value + " is in the array.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement