How can I read two double after typing?

Hi everyone!!
Thank you for reading me, I need your help.
I'm new (very very new) in JAVA programming.
I have a problem. I'm trying to write an application that reads a couple of
numbers (double). It shows a message on screen that says something like
'type a number', and then it reads it.
The thing is that the program doesn't stop for the input of the second
number and I don't know how to solve it.
Can you help me please?
My code is similiar to the following one:
System.out.println("Type the first number: ");
          try{
               x = System.in.read();
               }     catch(IOException e){
               System.out.println("It didn't work.");
System.out.println("Type the second number: ");
          try{               
               y = System.in.read();
               }     catch(IOException e){
               System.out.println("It didn't work.");
// We build the point
Point point1 = new Point(x,y);
Thank you very much for your attention and help.

You need to read the docs more carefully. read() just reads a single byte. If you type a capital 'A', read will return the number 65.
Look at the java.util.Scanner class. I think it has a readDouble method.
If you're not on 1.5 yet, use a BufferedReader around System.in to read a line, and then use Double.parseDouble.
http://java.sun.com/docs/books/tutorial/essential/io/index.html

Similar Messages

  • How can I read two channels with fieldpoint and labview

    I'm trying to read two or more channels with the TC 120, and I follow the examples of sopport page, but doesn't work.
    What can I do?

    For more information about reading or writing to or from multiple channels in Fieldpoint, please refer to:
    How Do I Read or Write to Multiple Channels on a Fieldpoint Module in LabVIEW?
    This should enable you to read multiple channels. The only other option available is to use one fp open.vi, multiple Create Tag.vi's and multiple FP Tag Read.vi's.

  • How can I limit a double value to two decimal place?

    How can I limit a double value to two decimal place?
    Java keeps on adding zero's to a simple double subtraction:
    1497 - 179.64 = 1317.3600000000001The answer must have been simply: 1317.36

    If the trouble is with output ...
    If the trouble is with value accuracy ...The trouble is with OPs understanding of and/or expectations of IEEE 754 floating point numbers. o_O
    [And it's probably a view (output) issue.]
    how can i actually use numberformat to cut those
    unwanted decimal places?Read the API - Puce already provided the link.

  • How can I clear a form after submitting and saving the data in the iOS Acrobat Reader App

    How can I clear a form after submitting and saving the data in the iOS Acrobat Reader App

    Darrell,
    Thanks for this response. After I posted mine, I saw that the resetForm JavaScript method is documented as being supported starting with version 10.5: http://www.adobe.com/devnet-docs/acrobatetk/tools/Mobile/js.html
    But I haven't been able to get it to work. Can you clarify if support was indeed added and if it works for you?

  • Using Lab view ver 6,How can I read a cell of excel file right after I write to it

    How can I read a specif cell of an Excel file using Labview VI.

    Hi,
    Attached is a LV6.1 VI which will read a cell.
    It will be looking for a sub VI found in the example C:\Program Files\National Instruments\LabVIEW\examples\comm\ExcelExamples.ll​b.
    The returned value is a string value but there is no reason why it couldn't be a number. Just connect a numeric to the type connector of the Variant to Data function.
    Hope this helps.
    Regards
    Ray Farmer
    Regards
    Ray Farmer
    Attachments:
    Get_Cell_Value.vi ‏41 KB
    Write_Table_To_XL.vi ‏101 KB

  • How can I read a column of numbers saved as .txt and display as a wave?

    Hi Tiano
    LabVIEW General
    Ask:
    Please enter a one-line summary of your question
    Resources
    • Technical Support
    • Development Library
    • Measurement Encyclopedia
    "data/time reading into chart"
    "In the attached file, I am trying to read the first column of data, and the next column is the value on the x-axis I want it plotted at. How do I read two columns of different data? I have looked in the books I have access to and the help within Labview but am still having trouble.
    Thank you,
    Ellie"
    data_set (Plain Text, 3K)
    -posted by Ellie on 9/11/2001
    markwysong on 9/11/2001 answered:
    "Ellie,
    The first thing you need to do is to read your file in as a spreadsheet file. Then, you display it in a chart.
    That sounds simple, but looking at your dataset, there's a few things you should know. First, the "read from spreadsheet VI" is looking for data in columns, like your data set, but columns separated by tabs. Therefore, your data must be saved that way; currently, it doesn't seem that it is. Another thing; you must skip the header portion (labels) of your file when reading.
    Next, it would be easier if your time was first, and your data was second in your columns, but that can be overcome. In the VI I am including, I have copied your data set into a file called data.txt, and I've removed the header and separated the columns with a tab. Then, I read in the data, and I break out each column so I can put the time first, and then I combine them again into a cluster so it can be displayed on an XY chart.
    Take a look!
    Mark"
    Graph data from file (Binary Executable, 20K)
    data.txt (Plain Text, 3K)
    This answer has not yet been rated.
    Rate this answer:
    Mikael Garcia on 9/11/2001 answered:
    "Ellie,
    Here is one way of doing it. Take a look at this example (compatible with LabVIEW 4.1 and up) and post comments if you need further help. Basically, I read your file as text; split it; and make use of the Spread sheet string to Array function before I plot your data. Hope this helps./ Mikael"
    ExtractAndPlot.vi (Binary Executable, 36K)
    This answer has not yet been rated.
    Rate this answer:
    Ellie on 9/12/2001 commented:
    "Thank you. I am trying to get the data from the text file into a string and am having some trouble. I am reading the file from a spreadsheet, and sending the output array to "Array to Spreadsheet String", but I'm not sure this is what I want to do. Is there another way to make an array into a string? Do I need to reformat my data?
    Can you offer me any advice?
    Thank you."
    data_1 (Plain Text, 3K)
    Mikael Garcia on 9/12/2001 commented:
    "I noticed that you changed your file format according to what was said here. Yes, this new file of yours is easier to use but your original file does not have to be changed. Take a look at this example. I now added the file-read part. It will give you a dialog to locate your data file (use this VI with your original file with the header since this VI includes a string split function). Hope this helps. /Mikael"
    ReadExtractandPlot.vi (Binary Executable, 35K)
    Niko on 9/12/2001 answered:
    "If you read this file with the "read from spreadsheet file.vi" you get you
    data in a 2-D-array. Now it is easy with array- and cluster-functions to
    handle the data the way you want.
    hope that helps, Niko"
    This answer has not yet been rated.
    Rate this answer:
    I intend to read from a .txt file that contains a column of numbers. After reading I want to display it as a waveform. In fact the numbers represent points along a waveform/graph of Flow vs. time. Thus I want to have this info in the chart or graph with flow in the y0axis and time in the x-axis. Can someone give me some detailed help please? Thank you in advance.
    Attachments:
    The_file.txt ‏18 KB

    All you have to do is use Read From Spreadsheet File.vi that's on the File I/O palette. For your example .txt, set the Transpose input to true and wire the First Row output to a waveform graph. The only problem I see is that since your file doesn't contain any sampling info, the time axis will be relative. If have that information elsewhere, then you can put a build waveform function between the read and the graph. Wire the First Row output to the Y input Build Waveform and add t0 and dt values. I've attached an example.
    Attachments:
    Graph_from_text.vi ‏29 KB

  • How can I use two monitors to increase workspace?

    how can I use two monitors to increase workspace?

    Drag the tabs of any After Effects windows you want to the second monitor.

  • How can i read header text?

    how can i read header text?
    ie, i want to read two values that are stored as header text in purchase order.
    how can i retrieve that values?

    Hi,
    The long texts of a document are stored in a encrypted format in the STXH and STXL tables, where STXH stores the header information of the
    long text like TDOBJECT, which indicates which text object the long text belongs to, TDID which indicates the Text ID and TDNAME which is
    the actual name of the long text.
    As these texts are stored in a encrypted format, the text cannot be read using a SELECT statement. You will have to use the function READ_TEXT. The easiest way of getting to know the parameter values is to go to a document, open the long text in a full screen mode. For example, when you wan to see the long text for a Purchase order, go to transaction ME23n. Assume, you want to see the parameters for the Header Text. In the first Tab Strip Control, click on the Texts tab and select the Header Text node on the left hand side, which will display the text on the right hand side. Now, double click on the text editor on the right hand side. This will open the text in the full screen mode. In the menu Go To --> Header, you should be able to see the values for all the three parameters we discussed above. We will have to do the same thing for whichever text parameters we want to see.
    TREC-TDSPRAS = SY-LANGU.
    TREC-TDID = 'ECCS'.
    TREC-TDOBJECT = 'ZECCS'.
    TREC-TDNAME = Z_ACCOUNT.
    CALL FUNCTION 'READ_TEXT'
    EXPORTING
    ID = TREC-TDID
    LANGUAGE = TREC-TDSPRAS
    NAME = TREC-TDNAME
    OBJECT = TREC-TDOBJECT
    TABLES
    LINES = LINES
    EXCEPTIONS
    ID = 1
    LANGUAGE = 2
    NAME = 3
    NOT_FOUND = 4
    OBJECT = 5
    REFERENCE_CHECK = 6
    WRONG_ACCESS_TO_ARCHIVE = 7
    OTHERS = 8.
    Details:
    Language DE
    Text ID F01 Header text
    Text Object EKKO Purchasing doc. header texts
    Regards,
    Shiva Kumar

  • How can I read epub ebooks from public libraries?

    Hallo,
    how can I read ebooks in epub format I have downloaded from public library on the iPad? They are valid for 7 days, I can open them with Adobe Digital Edition.
    I get them into iTunes, I even get them on the iPad. But I am getting an error message when I try to open them with iBook.
    If iBook can't read them, is there another app I could use?
    Hopefully somebody could help.
    Thanks, foxbetti

    how can I read ebooks in epub format I have downloaded from public library on the iPad? They are valid for 7 days, I can open them with Adobe Digital Edition... If iBook can't read them, is there another app I could use?
    You've answered your own question. Basically, you use Adobe Digital Editions (or Sony Reader Library) software which is keyed with your valid Adobe ID to manage content downloaded to an "authorized" computer for transfer to compatible "authorized" mobile devices. However, as far as I know at this time, the iPad is not yet supported by either application.
    Here is what Adobe says:
    Some digital publications that you purchase online or check out from a library may contain digital rights management (DRM) protection that restricts the items from being shared with others. In the past, this could limit the ability to read your items on additional computers owned by you. It could even prevent you from moving your items when you bought a new computer.
    Digital Editions helps ensure that your eBooks and other digital publications are not "locked" on one computer — they are assigned to you through your Adobe ID. Digital Editions also adds support for the next generation of mobile devices.
    Adobe membership is free and registration only takes a minute. As a member, you have access to trial downloads, hundreds of free product extensions, and special community areas. Your membership also allows you to view and manage your activity in the Adobe Worldwide Store.
    An Adobe ID is a free and a nonintrusive way of identifying users — you need only provide a name, country, and e-mail address. You can create your Adobe ID when prompted within Digital Editions as you authorize your computer, or go directly to the Adobe.com membership site.
    Once you authorize your computer with Digital Editions, the application looks for eBooks already on the computer and converts copies of the items to a new named account license. You can then transfer those eBooks to other computers. If you have eBooks on multiple computers, you need to authorize each one with Digital Editions prior to transferring eBooks between them.
    Important: Digital Editions converts eBooks that have been purchased with Acrobat, Reader, or earlier versions of Digital Editions. However, items licensed using Easy Activation can only be converted on the same computer with which they were originally purchased. If you are contemplating buying a new computer, changing the hard drive, or upgrading the operating system, consider keeping your old computer intact unless you bought all of your books with Acrobat or Reader using Named Activation.
    Digital Editions detects borrowed eBooks and displays them in the Borrowed bookshelf. However, if you borrowed an eBook with Acrobat or Reader, you cannot transfer that book to another computer. You must return the library item and then borrow the item again using the current version of Digital Editions.
    Digital Editions does not require you to authorize your computer with an Adobe ID. This option is necessary to address concerns about some users' needs for privacy (for example, library patrons and minors). However with this option, protected items that you have already downloaded or will download later are tied to that particular computer and are not readable on other computers or devices. They also can't be restored from backup if the operating system is reinstalled.
    When you first launch Digital Editions, you are prompted to authorize your computer. You can decline, in which case your digital content will belong to the computer, not a named user account. Subsequently, you will be prompted to authorize your computer whenever you purchase an eBook, although the prompt dialog box provides a"“Don’t ask me again" checkbox.
    Digital Editions has an “Authorize this computer” menu item that you can use after initial installation.
    Important: If you authorize your computer with an Adobe ID, then it will always be associated with that Adobe ID. If you do not, the account is "anonymous". If you "anonymously" activate two computers, then there are two separate anonymous accounts, which cannot be merged. Thus, the eBooks on one computer can be upgraded to "belong" to a specific Adobe ID, but the eBooks on the other cannot. If you authorize the second computer with your Adobe ID, any subsequent purchases on it are associated with that ID and transferable to any computer authorized with that ID. However, the books that were purchased on the second computer prior to being activated are forever locked to that computer.
    You can activate up to six computers and six devices . If you reach the limit, contact Customer Service to increase your allowable activations. --Adobe Web Site

  • How can I open two application together ? Ex. Calendar and reminders ?

    How can I open two application together ? Ex. Calendar and reminders ?

    When you are in one app, press the home button and open another app. You can't see more than one app at a time, but you can have as many open as memory will allow.
    To quickly switch between the apps, double-click the home button. Active apps will be shown in the order you last used them. You can slide the active bar to see more of recent apps.

  • How can I have two itunes accounts on one computer?

    How can I have two itunes accounts on one computer?

    Not sure what you mean.
    An account is a user name and password.
    Sign into whichever account you want to use for purchasing.
    Authorize the computer for both account to listen to the content.

  • How can I combine two itunes accounts into one?

    How can I combine two itunes accounts into one?

    Items purchased from the iTunes Store are permanently associated with the account from which they were originally purchased.  Apple provides no way to change this.
    However, if you wish to put content from two accounts into a single iTunes library, you can easily do so.  Use the command File > Add File (or Folder) to Library.

  • How can we have two different Itunes libraries on one computer?

    How can we have two Itunes accounts on one computer?  I found info on the itunes help page but I do not know how to follow the steps given because I am not prompted with what it says I should be prompted with? Please help I don't want to delete one of our libraries

    Launch iTunes with the Shift key held down as needed, or use different Windows XP user accounts.
    (74282)

  • How can I use two displays with my Mac Mini?

    How can I connect two displays to my Mac Mini (newest generation with one thunderbold and one hdmi)?

    Have you tried connecting one to the HDMI output, and another to the Thunderbolt port (with the appropriate Mini DisplayPort-to-other connection adapter as needed)?

  • HT1660 How can I maintain two separate itunes accounts on one single device without erasing either set of data?

    How can I maintain two separate itunes accounts on one single device (iPhone 4) without erasing either set of data when syncing with itunes?

    Hi,
    Depends on what you trying to setup but for purchases, you can roll down at the very end of the iTunes/AppStore pages to logout of your current account and then login into a different one.  Then your purchase will be billded to this new account.  Everything will sync as you used to but in order to use the purchased content in iTunes or other devices, you will need to authorize them (you can have up to 5 devices authorized for an account).

Maybe you are looking for

  • Battery, photos, and "charge complete."

    My pod isn't a year old (I guess it is fifth generation). This weekend I loaded some photos on it. Now, all of a sudden it is not holding a charge for an hour. I was not having any battery issues prior to this. Moreover, I no longer get a "charge com

  • Old typo in WGM causing bounce backs

    Hi, We run our mail from an xserve. We set up a user (jonna)and published her name, but she should have been joanna. We soon realized our error and changed the name in the info section, as her details in the basic section where correct. However, when

  • Keynote + Macbook Pro + Mbox

    Have a Keynote presentation with Quicktime movies and sound and I need to output the sound using an Mbox. Have changed the sound output on the preference panel, but no luck yet. iTunes does, however playback the sound to the Mbox. Any suggestions?

  • Is there a way to bypass password entry when starting.

    I've installed Yosemite on my MacBook Pro.  Now I must enter my password each time I reboot or start-up.  Is this absolutely necessary, and if not, how do I get around it?  Thank you.

  • ICloud drive folder asks for mac password

    Hello everyone, I love to use iCloud for everything but now since iCloud drive it's security is really bad. When I try to save a pages file or when trying to export it, finder does not give  permission to do so. Even though I give my password. And wh