SHARE
TWEET

Untitled

a guest May 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package MyProjects;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class WhereIsItVersion2Demo
  6. {
  7.   public static void main( String[] args )
  8.   {
  9.     Scanner keyboard = new Scanner(System.in);
  10.     int[] numbers = new int[___];
  11.     int user_num, num_at = ___;
  12.     boolean num_found = _______;
  13.  
  14.     System.out.print( "Array: " );
  15.     for ( int i = 0; i < numbers.length; i++ )
  16.     {
  17.       numbers[i] = 1 + (int)(Math.random() * 50);
  18.       System.out.print( numbers[i] + " " );
  19.     }
  20.     System.out.print( "\nValue to find: " );
  21.     user_num = keyboard.nextInt();
  22.  
  23.     System.out.println();
  24.     for ( int i = 0; i < numbers.length; i++ )
  25.     {
  26.       if ( user_num == numbers[i] )
  27.       {
  28.         num_found = _______;
  29.         num_at = i;
  30.       }
  31.     }
  32.  
  33.     if ( num_found = true )
  34.       System.out.println( user_num + " is in Slot " + num_at + "." );
  35.     else
  36.       System.out.println( user_num + " is not in the array." );
  37.  
  38.   }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top