Results 1 to 4 of 4
- 05-15-2008, 06:48 PM #1
Member
- Join Date
- May 2008
- Posts
- 2
- Rep Power
- 0
How to create this if many inputs?
Helo, I wanna try to input 1,000 samples of 5 digits numbers so that they all can pass through this equation one by one to calculate the output, y.
y=(2x/4000)-1
Below is the samples, x looks like(any random 5 digits samples is ok, as far it can get correct):
18349
32456
95332
12373
42567
12456
92434
62435
52324
48349
18349
blah..
until one thousands sample numbers
Is it possible to write a Java program of this instead of excel?
The problem is how to create a Java program that can accept so many inputs at one time ?
- 05-15-2008, 07:29 PM #2
Here is a quick sample....
Java Code:public test(){ //Sample inputs limited to 800 to see the whole input for(int x=0; x<800;x++){ int t = new java.util.Random().nextInt(100000); if(t>9999){ //Filter those inputs that are less than 10000. System.out.println("Input: "+t+"\t Y = "+(((2*t)/4000)-1)); } } }Last edited by sukatoa; 05-15-2008 at 07:31 PM.
freedom exists in the world of ideas
- 05-18-2008, 03:41 PM #3
Member
- Join Date
- May 2008
- Posts
- 2
- Rep Power
- 0
Hi, sukatoe, thanks for the reply. However, "not random function".
Ignore the random as what I mean is have a list of sample data,
Now, I have saved my list of 1000s samples into a text format file
18349
32456
95332
12373
42567
12456
92434
62435
52324
48349
18349
blah..
until one thousands sample numbers
I would need a java program that can make every sample that pass through this formulae:
y=(2x/4000)-1
to get the output answers automatically one by one. Can you guide me how to do it?
Thanks.
- 05-18-2008, 04:22 PM #4
You may use Scanner class to capture the values from a text file....
You can test the code....Java Code:private static final getSamples() throws Exception{ ArrayList<Object> list = new ArrayList<Object>(); Scanner read = new Scanner(new File("samples.txt")); while(read.hasNext()) list.add(read.next()); read.close(); return list; }
For calculations, same as my first example, take a loop from the returned list
After every calculation, show also the answer directly....Last edited by sukatoa; 05-18-2008 at 04:31 PM.
freedom exists in the world of ideas
Similar Threads
-
Java program that stores user inputs
By staticy2003 in forum Advanced JavaReplies: 6Last Post: 01-24-2008, 07:46 PM -
Date Inputs
By hiranya in forum AWT / SwingReplies: 3Last Post: 11-06-2007, 05:11 PM -
Create a new variable
By mathias in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:48 AM -
how to create different arrays
By osval in forum New To JavaReplies: 2Last Post: 08-06-2007, 11:07 PM -
Create XML From XSD
By Jack in forum XMLReplies: 1Last Post: 07-09-2007, 12:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks