Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

create an array for seeker

wiredwirede2m
wiredwirede2m 


Create an array with 100 randomly chosen integers. Prompts the user to enter index of the array then displays the corresponding element value. If the specified index is out of bounds, display message Out of Bounds. Attachments
Tags Clarifications

Answers

JAVA Random Number Generator Solution

Seeker
Seeker 



Solution is attached. Attachments
Random100.java (1 K) Download Preview
enter an index to get the arrays value"); Scanner scanner = new Scanner(System.in); String sIndex = scanner.nextLine(); boolean validNumber = false; int index = -1; // loop until a valid integer can be parsed from the string passed in while(!validNumber){ try{

Screenshots
Purchase Answer

100 random numbers

dianagaby2002
dianagaby2002 



- generating 100 random integers and in the same time insering them into an Array
- prompting the user to provide an index
- checking if the index is between 1-100
- if index between 1-100, dysplaying the random number corresponding to that index
- if index is <=0, >100, dysplaying "Out of bounds"
Attachments
_100Randoms.java (1 K) Download Preview
System.out.println("Please enter index:"); //Reading the input int index = input.nextInt(); if((index >= 1) && (index <= 100)){ System.out.println("Number at index " + index + " is " + numbers[index]); }else{ System.out.println("Out of bounds."); } //closing the Scanner

Screenshots
Purchase Answer