Limuh
stranger
Reged: 08/19/08
Posts: 1
|
|
Hello, i am taking a hard time to do this thing into coding please help this is the problem. if the user chooses to do searching, the program will create an array consisting of 20 randomly generated integers between 1 and 100. The user then provide a search key between 1 and 100. the program should then display the contents of the array created and inform the user if the search key is in the array or not. if it is in the array, the index where it is located should also be displayed.
sorry im super new to this any help is apreciated..
Thanks!
|
lance_en
stranger
Reged: 08/20/08
Posts: 2
|
|
package com.test
import java.util.Random import java.io.IOException import java.io.InputStreamReader import java.io.BufferedReader public class ArrayTest { private static Random rand = new Random(100) private static int[] values = new int[20]
|
lance_en
stranger
Reged: 08/20/08
Posts: 2
|
|
public static void main(String[] args) { try { System.out.println("Please input a key to search ") BufferedReader reader=new BufferedReader((new InputStreamReader(System.in))) int key=Integer.parseInt(reader.readLine()) new ArrayTest().search(key) } catch (NumberFormatException e) { e.printStackTrace() } catch (IOException e) { e.printStackTrace() } }
|