Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-15-2008, 08:48 PM
Member
 
Join Date: May 2008
Posts: 2
sarahannel123 is on a distinguished road
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 ?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-15-2008, 09:29 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Here is a quick sample....

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)); } } }
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 05-15-2008 at 09:31 PM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-18-2008, 05:41 PM
Member
 
Join Date: May 2008
Posts: 2
sarahannel123 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-18-2008, 06:22 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
You may use Scanner class to capture the values from a text file....

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; }
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....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 05-18-2008 at 06:31 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java program that stores user inputs staticy2003 Advanced Java 6 01-24-2008 09:46 PM
Date Inputs hiranya AWT / Swing 3 11-06-2007 07:11 PM
Create a new variable mathias New To Java 1 08-07-2007 08:48 AM
how to create different arrays osval New To Java 2 08-07-2007 01:07 AM
Create XML From XSD Jack XML 1 07-09-2007 02:56 AM


All times are GMT +3. The time now is 09:34 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org