He wants to input in the program an undefinite number of (numbers like 1, 2 etc), all positive. With that done he wants the program to randomize these numbers and show them one at a time in a random distribution. i thought it was easier when he asked but i found out while writing it that its not that easy. i need help. anyone?
trombadorez
0
Newbie Poster
Recommended Answers
Jump to PostFirst you can have the user input the number of values to input into the data structure(arrays are a good choice). Then use a for loop to ask the user to put in each value.
Jump to PostAs the user enters numbers add them to a List ( http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html ). Then in a loop generate a random integer between 0 and the size() of the list. Get(int index) the element …
Jump to PostI would get rid of this
int numero;
I do input using the predefined scanner class
Scanner scan = new Scanner(System.in); System.out.println("Enter how many numbers will be added"); int nums = scan.nextInt(); System.out.println("Input the numbers"); for(int index = 0; index<nums; ++index) { int input …
Jump to PostThe code segment I provided earlier is just to get the numbers into the list. Sorry, but I don't know that much about random numbers. Try searching on google.com.
All 14 Replies
Grn Xtrm
84
Posting Pro in Training
trombadorez
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Grn Xtrm
84
Posting Pro in Training
trombadorez
0
Newbie Poster
Grn Xtrm
84
Posting Pro in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
trombadorez
0
Newbie Poster
BestJewSinceJC
700
Posting Maven
trombadorez
0
Newbie Poster
BestJewSinceJC
700
Posting Maven
trombadorez
0
Newbie Poster
BestJewSinceJC
700
Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.