Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 8th, 2009, 2:29 PM   #1
Johnboy
Programmer
 
Join Date: Feb 2009
Posts: 84
Rep Power: 6 Johnboy is on a distinguished road
Storing User Input in an array

Hello folks
Just a quick query I want to ask the user for a series of numbers, They can enter up to 100 if required but once they decide thats enough numbers they can exit the program. I want the input to be added into an array and then be able to display the contents of this array. Hints please.

double[] numbers;
numbers = new double[100];
Johnboy is offline   Reply With Quote
Old Oct 8th, 2009, 10:43 PM   #2
Raikiriu
Ex-CS & Math student.
 
Raikiriu's Avatar
 
Join Date: Feb 2009
Location: Canada(Quebec)
Posts: 187
Rep Power: 6 Raikiriu is on a distinguished road
Re: Storing User Input in an array

use a do-while loop and use the Scanner... with the do-while, use something like
java Syntax (Toggle Plain Text)
  1.  
  2. bool pQuit = false;
  3.  
  4. do{
  5. //Insert code here
  6. if(input = 'q')
  7. {
  8. pQuit = true;
  9. }
  10. } while(!pQuit);
__________________
On and off member, mostly lurking in the shadows of the java forums.
/~ http://signup.leagueoflegends.com/?r...c16b3998676588 ~/
Raikiriu is offline   Reply With Quote
Old Oct 10th, 2009, 3:19 PM   #3
exception
Critical Programmer
 
exception's Avatar
 
Join Date: Oct 2008
Location: Philippines
Posts: 172
Rep Power: 6 exception is on a distinguished road
Send a message via Yahoo to exception
Re: Storing User Input in an array

java Syntax (Toggle Plain Text)
  1.  
  2. double numbers = new double[100];
  3. Scanner sc = new Scanner(System.in);
  4. for(int i = 0;i<numbers.length; i++)
  5. {
  6. System.out.println("Enter Number: ")
  7. number = sc.nextDouble();
  8. }
__________________
|Knowledge alone is not POWER, Applied knowledge is POWER.
exception is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
timed user input sainiabhishek C 7 Apr 4th, 2009 4:13 PM
Compare array to input string! kong Visual Basic .NET 0 Mar 25th, 2009 10:29 PM
input data from user into array lilmul123 C++ 5 May 26th, 2006 9:29 AM
User Input for Number Format ericelysia1 Java 0 Jul 21st, 2005 3:41 PM
Installing IPB 2.03 bh4575 Other Web Development Languages 0 Apr 23rd, 2005 2:36 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:25 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC