Created
April 4, 2014 17:46
-
-
Save anonymous/9979510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class tesstt { | |
public static void main (String args []) { | |
System.out.print("Array: "); | |
int [] arr = new int[9]; | |
for (int i = 0; i < arr.length; i++) { | |
arr[i] = (int) (1 + (Math.random() * 50)); | |
System.out.print(" " + arr[i]); | |
} | |
System.out.print("\nValue to find: "); | |
Scanner s = new Scanner(System.in); | |
int find = s.nextInt(); | |
for (int i = 0; i < arr.length; i++) { | |
if (arr[i] == find) { | |
System.out.print(find + " is in the array.\n"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment