How do I input multiple numbers to go to multiple variables in one line?

I was wondering what I had to do to input 5 variables on one line. I have the program running fine, but I'm stuck at the part where it says "The numbers will be input five per line, on four lines".. Aside from poor grammar, it doesn't make any sense to me. Here's the whole question:
Write code that will fill the array twoDArray(declared in the line of code below) with numbers typed in at the keyboard. The numbers will be input five per line, on four lines. Use the following array declaration:I don't need any immediate help with the array itself, just the input (unless the input is directly related to the array). Just in case, I'm going to post my code. This is still very messy, because I'm not done, and it's might be somewhat sloppy as I'm new to 2d arrays (in java).
Thanks for the help.
import java.io.*;
class darrays
public static void main(String[] args) throws IOException
InputStreamReader inStream = new InputStreamReader (System.in);
BufferedReader stdin = new BufferedReader(inStream);
int[][] twoDArray = new int[4][5];
int x,y;
String input;
for (x = 0; x <= 3; x++)
     for (y = 0; y<=4; y++)
input = stdin.readLine ();
twoDArray[x][y] = Integer.parseInt (input);
for (x = 0; x <= 3; x++)
     for (y = 0; y<=4; y++)
System.out.print(twoDArray[x][y] + " ");
System.out.println("");
}     

Slightly off-topic
When I was learning Basic (good old Kemeny & Kurtz style, when Basic was simply a simplified Fortran, not Bill Gates style) you simply have to write
READ A, B, C, D, E
DATA 10, 20, 30, 40, 50
or something like
INPUT "A", A: INPUT "B", B etc.
In Java you are required to handle the mysteries of StringTokenizer...
Java 1.5 is promising to make it easier:
      Scanner sc = Scanner.create(new File("myNumbers"));
      while (sc.hasNextLong()) {
          long aLong = sc.nextLong();
      }where you get the longs (decimal formatted, separated with blanks) from a text file.
But not so easy as the good old INPUT statement.
Even C's scanf is not so easy, because has lots of subtleties
(when you finally mastered the esoteric art of using char* as strings, you are really fed up of char* strings, because they usually blow up due to buffer overflows or mere programmer errors, and start to use Java instead, even having to master the StringTokenizer and other classes.).

Similar Messages

  • Bash script question, how do I create multiple directories on one line

    I am making a package for amavisd-new (yes I am aware that there is one in community but I can't say I like the way it is done).
    I have an install script from which I want to create multiple directories if they do not exist.
    So I want to create a directory /var/spool/amavis with subdirectories of var tmp virusmails spammassassin .
    I can't seem to be able to find a way to do this on one line.

    pelle.k wrote:
    peets wrote:Hehe because it's less typing!
    Good one!
    Also, it's by far the more dynamic method.
    If you want to get pedantic, it's also far less efficient in terms of execution time: each iteration of the loop forks a new process, whereas using a single mkdir command forks only once.  The "best" way is the curly-braces method demonstrated above by chimeric.

  • How can I convert multiple files at one time and not one at a time

    How can I convert multiple files at one time and not one at a time

    Hi Plissey1950,
    Sorry for the lengthy delay to a response.  Are you trying to convert multiple files to individual PDF files at the same time? (not combine them).  If so, you'll need to use Adobe Acrobat for this function. The CreatePDF service does not have the ability to convert multiple files to multiple individual PDF files.
    Thanks,
    David

  • How can I activate multiple tags at one time?

    How can I activate multiple tags at one time?

    I'm pretty sure you can run this on a sub tree of /etc/tags
    http://dev.day.com/docs/en/cq/current/wcm/page_publish/tree_activate.html

  • How do you select multiple files at one time

    How do you select multiple files at one time

    Select one, and then either command-click another, or in list/column view, Shift-click the item at the other end of the range you want to select. Alternatively, click on a spot in the screen and drag the cursor until all the files are selected.
    (114308)

  • How do I select Multiple Pdfs at one time when I am combining files?

    How do I select Multiple Pdfs at one time when I am combining files?
    I can only select one pdf at a time.

    Hi,
    Please use either Firefox or Chrome to selelct multiple files.
    Thank you.
    Hisami

  • How do i delete  multiple emails at one time from iphone Mail account with iphone 4s?

    how do i delete  multiple emails at one time from iphone Mail account with iphone 4s?

    Better than that!
    http://www.youtube.com/watch?v=fKa-KFjUIGE
    Select a message, hold the move button, deselect the message while still holding the move button.
    A new window appears allowing you to move all messages to the trash.
    Bingo!

  • How can I have multiple users on one apple id?

    How can I have multiple users on one apple ID?
    ie: I have my apple ID with my own credit, how can I set up credit for my son under the same apple ID, so that he can still access the same apps I've already downloaded and paid for?

    I've been trying to figure out a clean way to do this too. I think you may need more than one Apple ID – one that is shared and used to purchase "sharable" items and then "individual" Apple IDs for you and your son. That's the idea that I'm pursuing for the moment.
    It seems that there must be a way to do this, App Store purchases for the Mac are licensed across multiple machines. iPhone app purchases have "all your devices" licensing. Makes me think that Apple has a process in mind for sharing an account (or associating a device with multiple accounts).
    Other things I've learned:
    - Apparently you can't merge Apple ID accounts. I asked about this once at an Apple Store and was told that there was no way to do it.
    - If you share an Apple ID the Messages app behaves in a somewhat surprising manner. It must use your Apple ID to decide where messages should be sent because all users get all messages. This can make it very hard to organize a surprise party :-)

  • How can I scan multiple pages to one file with MG 7120

    My printer does not have ADF. How can I scan multiple pages to one file on my MG 7120?

    Hi albabynyr,
    There is a program that comes with the printer called the IJ Scan Utility that can assist you with scanning multiple pages into a single file.  To scan using the IJ Scan Utility, please follow these steps:
    1. Start IJ Scan Utility by going to your Start menu, then selecting All Programs, then Canon Utilities, then  IJ Scan Utility (folder), then IJ Scan Utility (program).
    2. In the Canon IJ Scan Utility window that opens, click SETTINGS.... in the bottom right of the window. The Settings dialog box appears.
    3. Click the DOCUMENT SCAN option on the left pane of the window.
    4. In the right pane of the window, locate the SELECT SOURCE field and select the DOCUMENT option.
    5. Set the color mode, document size, and scanning resolution as required in the rest of the fields shown in the window. Click DOCUMENT SCAN ORIENTATION SETTINGS... to specify the orientation of the documents to be scanned.
    6. In the SAVE SETTINGS section of the window, you will select the save format and location of the document you are about to scan.
    a.) In the FILE NAME field, specify the name you would like to give the file. By default the filename will begin with IMG; you can remove IMG and change it to whatever you would like to name the file.
    b.) In the DATA FORMAT field, use the drop-down arrow to select the PDF (Multiple Pages) option.
    c.) In the SAVE IN field, please navigate to the area where you would like the file to be saved once it is scanned in. By default, the file will be saved in the DOCUMENTS folder.
    7. Once all settings have been selected, click the OK button at the bottom of the SETTINGS (DOCUMENT SCAN) window. The IJ Scan Utility main screen appears.
    8. Click the DOCUMENT button. Scanning starts. After a page has scanned, the screen to continue or end scanning appears. If you have more pages to scan, place the next page on the platen and click Scan.  Do this each time a page has completed scanning.  After the last page has been scanned, click Exit. Scanned images are saved in previously selected folder location specified in the SETTINGS... window. Click the CANCEL button to cancel scanning if needed during scanning.
    Hope this helps!
    This didn't answer your question or issue? Please call or email us at one of the methods on the Contact Us page for further assistance.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • How do I scan multiple pages into one document?

    How do I scan multiple pages into one document?
    HP Photosmart 5514-e-All-in-One Printer B111h
    Model CQ 183 A

    Hi,
    Have you tried this (using PDF format).
    Launch the scan from the HP Solution Center
    Click Change Settings.
    Select the desire Scan Shortcut, then click Save to file save options
    Make sure Create One File per scanned page... is Unchecked, Approve and perform the Scan.
    Regards,
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How do i scan multiple pages into one pdf file

    How do I scan multiple pages into one pdf file?

    That depends on your scanning software. Adobe Reader doesn't scan.

  • How do i put multiple albums into one huge album collection?

    How do i put multiple albums into one huge album collection?
    Some examples include: Linkin Park - Studio Collection, Michael Jackson - The Indisposable Collection

    Hi skullkrunch3r,
    Thanks for visiting Apple Support Communities.
    If you "Get Info" on the tracks that are part of your collection, you can use the Compilation option in iTunes.
    In iTunes 8 and later, you find the option to mark multiple items as "Part of a compilation" in the Options tab of the Multiple Item Information window.
    See this article for more information on marking your albums as part of a compilation:
    Why aren't songs with the same album art grouped together?
    http://support.apple.com/kb/TS1468
    Best Regards,
    Jeremy

  • How do I view multiple images in one window?

    How do I view multiple images in one window?  I want to compare images side by side, not in tabs.

    Thank you, Barbara.  I found that I had to close the program after I turned on "allow floating documents" and restart, before I was able to go to "float all in windows". 

  • How do I scan multiple pages into one document using the CanoScan LiDE 200?

    How do I scan multiple pages into one document using the CanoScan LiDE 200?
    I can't seem to find a way to get them to scan continuously, or a way to stitch them together afterwards.

    Hi dagda24,
    You can scan multiple pages into a single document with the scan to PDF option.  Use the following steps to do so:
    1.  Open MP Navigator.
    2.  Click One Clcik.
    3.  Click Save to PC.
    4.  Change the File Type from PDF to PDF (multiple pages).
    5.  Make any other changes as needed, then click scan.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • How do I save multiple songs as one file?

    How do I save multiple songs as one file?

    Mhoopes wrote:
    How do I save multiple songs as one file?
    There are two ways:
    1.  Put the individual song files into a folder, and then Zip the folder.  This creates a single .zip file.  (Note however, that a .zip file is not playable in a normal player: it is just a "holder" for the song files.)
    2.  Use an audio editor such as Audacity to concatenate the individual song files into a single song file.  This creates a single file can be played in a normal player such as iTunes.
    Technique #2 is the one normally used to create a continuous mix.

Maybe you are looking for

  • Trying to delete files from my finder on my MacBook Pro

    Hi guys, I had some video files that I downloaded and transferred them to my external hard drive which is connected via wireless network. I then deleted the files from my computers hard drive and then emptied my recycle bin/trash. As you can see from

  • Quake3 refuses to work

    Hi, completely "out of the sudden" my quake3 quit working. When I fire it up to connect a server (/usr/local/bin/quake3-smp +set fs_game cpma +connect myserversip:port) then it hangs on awaiting gamestate. I actually have to kill it with "-9", just a

  • Why does PSE7 Organizer lock up?

    On starting Organizer, the tree of files appears on the left and thumbnails appear on the right, as usual. Then a small box appears in the middle of the screen with the title, Adobe Photoshop Elements – Updating.  A blue bar moves across this small b

  • Labview Installer Problems

    Hi, I have been using Labview 8.2.1 Professional for years developing customer user interfaces. I have started to receive several field incidents of installer failures. Some of the error encountered include: - "Fatal Error!! Required MSI property Per

  • How  to  hide a block  from a  selection screen.

    Hello Friends,   I have a new reqirement in which a main program has two transactions. Both the transactions have the same fields and parameters.     Now I am asked to add some fields in only one transaction without disturbing  the other txn. For thi