# Thread: How to create this if many inputs?

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 ?

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.

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.

4. You may use Scanner class to capture the values from a text file....

Java Code:
```private static final getSamples() throws Exception{
ArrayList<Object> list = new ArrayList<Object>();
Scanner read = new Scanner(new File("samples.txt"));
return list;
}```
You can test the code....

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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•