Programming Forums
User Name Password Register

RSS Feed

Thread Tools Display Modes
Old Oct 8th, 2009, 3:29 PM   #1
Join Date: Feb 2009
Posts: 84
Rep Power: 9 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, 11:43 PM   #2
Ex-CS & Math student.
Raikiriu's Avatar
Join Date: Feb 2009
Location: Canada(Quebec)
Posts: 192
Rep Power: 9 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)
  2. bool pQuit = false;
  4. do{
  5. //Insert code here
  6. if(input = 'q')
  7. {
  8. pQuit = true;
  9. }
  10. } while(!pQuit);
Resident Shadow-Dweller
Raikiriu is offline   Reply With Quote
Old Oct 10th, 2009, 4:19 PM   #3
Software & Web Developer
exception's Avatar
Join Date: Oct 2008
Location: Philippines
Posts: 173
Rep Power: 10 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)
  2. double numbers = new double[100];
  3. Scanner sc = new Scanner(;
  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


« 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 5:13 PM
Compare array to input string! kong Visual Basic .NET 0 Mar 25th, 2009 11:29 PM
input data from user into array lilmul123 C++ 5 May 26th, 2006 10:29 AM
User Input for Number Format ericelysia1 Java 0 Jul 21st, 2005 4:41 PM
Installing IPB 2.03 bh4575 Other Web Development Languages 0 Apr 23rd, 2005 3:36 AM

DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:37 PM.

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