Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MyProjects;
- import java.util.Scanner;
- public class WhereIsItVersion2Demo
- {
- public static void main( String[] args )
- {
- Scanner keyboard = new Scanner(System.in);
- int[] numbers = new int[___];
- int user_num, num_at = ___;
- boolean num_found = _______;
- System.out.print( "Array: " );
- for ( int i = 0; i < numbers.length; i++ )
- {
- numbers[i] = 1 + (int)(Math.random() * 50);
- System.out.print( numbers[i] + " " );
- }
- System.out.print( "\nValue to find: " );
- user_num = keyboard.nextInt();
- System.out.println();
- for ( int i = 0; i < numbers.length; i++ )
- {
- if ( user_num == numbers[i] )
- {
- num_found = _______;
- num_at = i;
- }
- }
- if ( num_found = true )
- System.out.println( user_num + " is in Slot " + num_at + "." );
- else
- System.out.println( user_num + " is not in the array." );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement