Problems with the Scanner class and the decimal point

I'm creating a GUI so to get the user input (double value) I use a jText field and the Scanner to read that value:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String time = jTextTime.getText();
       double t = new Scanner(time).nextDouble();
        String cy = Double.toString(t);
        jTextCycles.setText(cy);
    }                                  The problem is that the decimal point it's a comma so if I write:
1.2
t = (Error InputMismatchException)
1.236
t = 1236.0
1,2
t = 1.2
So I try using the parse method to get the double value:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String time = jTextTime.getText();
       double t = Double.parseDouble(time);
        String cy = Double.toString(t);
        jTextCycles.setText(cy);
    }                            In this case the method parseDouble() takes the dot as the decimal point so if i write:
1.2
t = 1.2
1.236
t = 1.236
1,2
t = (Error InputMismatchException)
� What can I do to Scanner class to accept the dot as the decimal point?
I think that the problem is becouse in some countries (I'm from Colombia) the decimal point is a comma and in others is the dot.
Thanks

From the Javadocs for Scanner:
Localized numbers
An instance of this class is capable of scanning numbers in the standard formats as well as in the formats of the scanner's locale. A scanner's initial locale is the value returned by the Locale.getDefault() method; it may be changed via the useLocale(java.util.Locale) method.
If you change your locale to one of those that does use a comma for a decimal point, it should work.

Similar Messages

  • I can't text a contact but can voice phone them. I don't have the problem with any other contact and the contact is not blocked. I have an iphone5.0 OS 8.1.3

    I can't text a contact but can voice phone them. I don't have the problem with any other contact and the contact is not blocked. I have an iphone5.0 OS 8.1.3. I used to be able to text them with no problem. The only difference I can think is that this problem may have started since I downloaded the OS I am using now
    cycleluke

    Wasn't responding to you. Please show me links where this helped.
    Apple isn't showing any system problems: https://www.apple.com/support/systemstatus/

  • Any problems with Adobe CS5.5 and the Maverick system?

    Has anyone had any problems with Adobe CS5.5 and the new Maverick OS? I don't want to install if there are issues. Thanks!

    First thing I would suggest is to upgrade your server OS to a newer version if possible. Secondly try removing the apps out of the allowable apps list and instead change it so that you allow the apps that are within the specific application folder, ex: Applications/Adobe Photoshop CS5
    I had similar problems with CS5 apps and by adding the apps by allowable folder instead it corrected my problem. Granted, if you have savvy users, there is the potential to open a can of worms here but it was the only way I could get it to work for "standard" non-admin user types.

  • I'm having problems with videos, they shake and the images break up back and forth into striped colors, how do I fix this?

    I'm having problems with videos, they shake and the images break up back and forth into striped colors, how do I fix this?

    1) This is because of software version 1.1. See this
    thread for some options as to how to go back to 1.0,
    which will correct the problem...
    http://discussions.apple.com/thread.jspa?threadID=3754
    59&tstart=0
    2) This tends to happen after videos. Give the iPod a
    minute or two to readjust. It should now be more
    accurate.
    3) This?
    iPod shows a folder icon with exclamation
    point
    4) Restore the iPod
    5) Try these...
    iPod Only Shows An Apple Logo and Will Not Start
    Up
    iPod Only Shows An Apple Logo
    I think 3,4, and 5 are related. Try the options I
    posted for each one.
    btabz
    I just noticed that one of the restore methods you posted was to put it into Disk Mode First rather than just use the resstore straight off, I Have tried that and seems to have solved the problem, If it has thank you. previously I have only tried just restoring it skipping this extra step. Hope my iPod stays healthy, if it doesnt its a warrenty job me thinks any way thanks again

  • I am having problems with my macbook pro and the dock.  About every fourth time I start the computer, the dock flashes on and off, then goes completely off and all I get is the spinning ball with brief moments of the cursor.  But the computer locks up.

    I am having problems with my macbook pro and the dock.  About every fourth time I start the computer, the dock flashes on and off, then goes completely off and all I get is the spinning ball with brief moments of the cursor.  But the computer locks up.

    Do you have Parallels installed by any chance?  There is a known problem that causes symptoms similar to this.  You do not need to actually be running Parallels at the time and nothing in ActivityMonitor would point to Parallels.  An update corrects the problem:
    http://kb.parallels.com/111541

  • Problems with Deployment, Startup classes and MBeanHome

    Hello,
    we have the following problem: How to initialize our application
    correctly???
    We are using MDBs as message consumers but have to guarantee the order of
    incoming
    messages. Due to a shortcoming in the JMS implementation (Order of
    redelivered messages
    is not guaranteed before WLS 8.1!!!) we are using a singleton class to keep
    the health state
    of the different message queues within the application (controlling whether
    the MDBs are
    supposed to proceed with processing or to discard any incoming messages).
    Thus the MDBs
    have to access this singleton, what implies latter has to be initialized
    prior to the application
    deployment. That's what we are using a startup class for, which is marked to
    be loaded before
    appplication deployment...
    Fortunately the according bug is fixed with WLS 7.0.2.0, so the class is
    loaded, but we are
    not able to access the MBeanHome interface (We like to register MBean to
    provide
    adminstrative access to the health state)!!!
    javax.naming.NameNotFoundException: Unable to resolve
    'weblogic.management.home.localhome' Resolved: 'weblogic.management'
    Unresolved:'home' ; remaining name 'home.localhome'
    at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
    So when is the MBeanServer started???
    Before application deployment??? After??? Is there any way to tell WLS not
    to load the startup
    class before the MBeanServer is available respectively the MBeanHome is
    accessible via JNDI
    but before application deployment???
    Any hints are welcome!!!
    Regards,
    CK

    this seems like a bug. the mbeanhome should be available for lookup in
    startup classes. also posting to system management newsgroup.
    "Carsten Kaiser" <[email protected]> wrote in message
    news:[email protected]..
    Hello,
    we have the following problem: How to initialize our application
    correctly???
    We are using MDBs as message consumers but have to guarantee the order of
    incoming
    messages. Due to a shortcoming in the JMS implementation (Order of
    redelivered messages
    is not guaranteed before WLS 8.1!!!) we are using a singleton class tokeep
    the health state
    of the different message queues within the application (controllingwhether
    the MDBs are
    supposed to proceed with processing or to discard any incoming messages).
    Thus the MDBs
    have to access this singleton, what implies latter has to be initialized
    prior to the application
    deployment. That's what we are using a startup class for, which is markedto
    be loaded before
    appplication deployment...
    Fortunately the according bug is fixed with WLS 7.0.2.0, so the class is
    loaded, but we are
    not able to access the MBeanHome interface (We like to register MBean to
    provide
    adminstrative access to the health state)!!!
    javax.naming.NameNotFoundException: Unable to resolve
    'weblogic.management.home.localhome' Resolved: 'weblogic.management'
    Unresolved:'home' ; remaining name 'home.localhome'
    at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
    So when is the MBeanServer started???
    Before application deployment??? After??? Is there any way to tell WLS not
    to load the startup
    class before the MBeanServer is available respectively the MBeanHome is
    accessible via JNDI
    but before application deployment???
    Any hints are welcome!!!
    Regards,
    CK

  • Problem with an unavailable server and the "Offline address book" rol

    I have a site with two Exchange 2007 servers and tried to install a new Exchange 2013 but the process did not end well.
    Now the 2013 server has the role of "Offline address book" and is no longer available which creates multiple problems. How I can do to remove the references to the 2013 server and move the role referred to one of the existing Exchange 2007 servers? 

    My recommendation would be to fix whatever went wrong and complete the setup.
    The server is probably the generation server for a new offline address list.  Check that by entering the following command.
    Get-OfflineAddressBook
    If there's a new list created by Exchange 2013 setup, you can simply remove it using Remove-OfflineAddressBook, and that should take care of what you're seeing.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

  • Problems with importing .MP4 file and the audio in FCP 6

    Hi all,
    I am pretty new to Final Cut Pro and have just approached my first project.
    I have a Samsung VP-MX20
    http://www.samsung.com/uk/consumer/detail/spec.do?group=cameracamcorder&type=cam corder&subtype=flashcamcorder&model_cd=VP-MX20/XEU&fullspec=F
    *Codecs H.264, AAC.*
    I needed some space on the camera so halfway through a holiday i transfered all the video files from the camera to my Laptop.
    I have imported these files from the hardrive
    Vid rate - 25 fps
    compressor - H.264
    Pixel Aspect - PAL - CCIR 601
    What seems to be the problem is ok when i drag the clip from the viewer to the canvas and apply insert, i get the box that says 'Change Sequence settings to match the clip settings?
    i click yes and when the clip is layed out on the timeline there is a red line above the timeline, when i play the clip i only get bleeps as audio and not the original sound.
    If i drag the playhead i can hear the audio but if i try to play all i hear us bleeps plus if i import an mp3 the red line appears above the timeline and the same applies
    can anyone help me here.
    Thanks
    Elles

    Hi Zak,
    many thanks for your reply, i have contacted Apple and taking your advice and using compressor i have converted the codec H.264 to Apple Pro Res 422 for interlaced material.
    I have imported this file and when i drag once again from the viewer to canvas i get the standard box asking to change the sequence to match the clip.
    I am still getting the red line above the timeline and bleeping as audio.
    any idea?

  • Problems with OC4J EJB deployment and the data-sources.xml file

    I am running 2 Windows 2000 Machines one with the 8.1.7 database another with iAS 1.0.2.2.1 and OC4J.
    I am trying to deploy a 3rd party EJB-based application whic seems to have deployed successfully except when I try to test the EJB deployment via a jsp it can't connect to the database, giving the error:
    1/16/02 4:52 PM VerySimple: Servlet error
    java.lang.NoClassDefFoundError: com.netexp.user.UserManagerHome
    at com.netexp.beans.BeanHelper.class$(Unknown Source)
    at com.netexp.beans.BeanHelper.getUserManagerBean(Unknown Source)
    at /very_simple.jsp._jspService(/very_simple.jsp.java:48) (JSP page line 27)
    at com.orionserver[Oracle9iAS (1.0.2.2.1) Containers for J2EE].http.OrionHttpJspPage.service(OrionHttpJspPage.java:54)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpApplication.serviceJSP(HttpApplication.java:5459)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.JSPServlet.service(JSPServlet.java:31)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:508)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:177)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:576)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:189)
    at com.evermind[Oracle9iAS (1.0.2.2.1) Containers for J2EE].util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    I try to update the file using the installdatasource switch thus:
    C:\Oracle\iSuites\j2ee\home>java -jar admin.jar ormi://localhost admin adm_pwd -application apptricityII -installDataSource -jar %ORACLE_HOME%\jdbc\lib\classes12.zip -url jdbc:oracle:thin:@db_host.unitas.com:1521:db_name -connectionDriver oracle.jdbc.driver.OracleDriver -location jdbc/pool/OracleDataSource -username scott -password tiger
    And get the following error:
    Exception passing by from remote server: java.lang.InstantiationException: No class specified for jdbc/pool/OracleDataSource
    java.lang.InstantiationException: No class specified for jdbc/pool/OracleDataSource
    <<no stack trace available>>
    Error adding source: No class specified for jdbc/pool/OracleDataSource
    Please advise.
    I have followed the instructions in 'EJB Primer' and 'Using Oracle9iAS Containers for J2EE' to no avail. And I can't find any meaningfull data-sources.xml samples. I have been struggling with this for some time.
    Is there any other file, do I need to bind anything?
    I'd appreciate your assistance.
    Thank you
    Louiza

    Hi Louiza,
    Show us your web.xml and ejb-jar.xml files as well as your
    data-source.xml file.
    Thanks,
    Avi.

  • Problems with vertical cell borders and the default table style

    When laying out tables in Word, I like to use thin horizontal lines (cell borders) and thick-ish white vertical lines. The vertical white cell borders create a subtle negative space that is less cluttered than the typical boxed-in-all-sides style.
    Issue 1.
    In Pages, horizontal cell borders seem to take precedence over vertical cell borders so my vertical white line trick doesn't work. Is there a way to force my vertical white cell borders to "show up" over my think black horizontal cell borders?
    Issue 2.
    So, for the time being, I'm not using vertical white cell borders in tables; instead, I set the vertical cell borders to "none." Unfortunately, when I try to set the default table style using a table with no vertical cell borders, Pages adds the vertical cell borders anyway. Does anyone know a way to get Pages to surrender?
    Message was edited by: Steve in Seattle

    I must apologizes.
    It seems that I didn't understand well the problem.
    Issue 1.
    In Pages, horizontal cell borders seem to take precedence over vertical cell borders so my vertical white line trick doesn't work. Is there a way to force my vertical white cell borders to "show up" over my think black horizontal cell borders?
    NO
    Issue 2.
    So, for the time being, I'm not using vertical white cell borders in tables; instead, I set the vertical cell borders to "none." Unfortunately, when I try to set the default table style using a table with no vertical cell borders, Pages adds the vertical cell borders anyway. Does anyone know a way to get Pages to surrender?
    I checked and here, aftere defining a new default format with vertical lines set to none, this format is used when I cvreate a new table.
    But the same with horizontal lines doesn't apply.
    _Go to "Provide Pages Feedback" in the "Pages" menu_, describe what you wish.
    Then, cross your fingers, and wait _at least_ for iWork'10
    Yvan KOENIG (from FRANCE mardi 28 avril 2009 22:31:45)

  • I have a problem with my Internet Security and the new Firefox, where can I get the previous version which I had before my system crashed?

    Hi I use CA Internet Security Suite which checks ALL pages and searches, but it does not work with this version, also I wish to use Goggle Toolbar which ALSO does not work with this version where can I get the previous version? As my harddrive crashed I have had to install windows 7 and this version doesn't seem to allow me to change my homepage, why is this? Cheers Ernest

    You can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html
    Mozilla are working to prevent Mac users with non-compatible systems from getting the notification about Firefox 4, and also not displaying the "Download Firefox 4" button on http://www.mozilla.com

  • Problems with old apple id and the cloud

    Ok, I have an Apple ID, but my icloud keeps coming up with my OLD apple id which is linked to an email address I no longer have. How do I fix this and reconnect to the cloud? As it is, I cant connect to a bunch of stuff because I have too many ids. Help!
    Thanks in advance.

    Hello there, MrsMcThi.
    The following Knowledge Base article provides some good recommendations for troubleshooting your issue:
    iOS 7: If you're asked for the password to your previous Apple ID when signing out of iCloud
    http://support.apple.com/kb/ts5223
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • How to find the Message Class and ID for messages in WebIC

    Dear Experts,
    I get some error messages in the WebIC
    I went to SAAB to activate and see details on the error messages
    But, what i am missing is the the message class and the ID information
    Can any one tell me if there is a work around to check and find out which message class and ID the message belongs to
    Regards,
    Raj

    Hi Raj,
    Put a break-point in method get_instance or ADD_MESSAGE of class cl_bsp_wd_message_service.
    Best regards,
    Caíque Escaler

  • Problem with large option class during runtime 11.5.10

    It seems like our Oracle Configurator has a problem with loading multiple large option classes with about 10,000 items under it. We are running 11.5.10. My guess is that Oracle has to load everything in the option class and at some point the server just gives up after loading so much data.
    Basically the model looks like this and was set up by Oracle themselves in 04. Overtime the option classes grew.
    --Base model
    ----Model A instance 1
    --------option class
    ------------10000 items
    ----Model A instance 2
    --------option class
    ------------10000 items
    ----Model A instance 50
    --------option class
    ------------10000 items
    Is there an optimal amount for an option class? Is the model structure possibly outdated and we should break up the option classes into models to alleviate some of the pain? Or are we at the limitation that Oracle Configurator can do and should peruse a custom solution?

    Funny thing really because the Case study for Chapter 4 is from our company that Oracle put together for us and its not working in the sense that it seems the servers can't handle the current model structure. I wouldn't blame the UI for these crashes and we already hide stuff from the user (ie, having to sort through all 10,000 items and hiding the BOM structure). Quick story of why i want to try and fix it is becuase the way its set up now in the model document is that 3 people could kill the server by basically saying "ok i selected this item for this location" (which would load the 10,000 items into memory on the server and not to the UI upon selection of the model) and then they would say... "ok now copy this selection to all these 50 places" (which would load those items again for each place that the item had to copied to) and BOOM server dead. I think sandeeps diagram of the changes is a really good idea and could help out alot and I tossed out that idea a few times before around my work place to help with the server issues. I feel that it would work but is it also possible that maybe configurator can't support our model the way they are wanting it to work?

  • Problems with a Lenovo X41 and a docking station

    I have problems with a Lenovo X41 and the docking station.
    Sometimes, when the laptop is undocked and used in other location, when I try to dock it again, some devices, such as mouse or keyboeard attached to the docking station, don't work.
    I will appreciate your help.

    I am also having the same issue you describe.

Maybe you are looking for