Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help on Float Values

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Help on Float Values

    Hi,

    I am a beginner in Java and I am currently learning about JOption pane. I have this below question plz.

    Using Strings I am accepting an input from the user and by using the Interer.ParseInt(variable) option I am able to multiply this two strings using the code below.

       String Length;
       Length = JOptionPane.showInputDialog("Enter the Length");
       String Breadth;
       Breadth = JOptionPane.showInputDialog("Enter the Breadth");
       System.out.println(" Area is " + (Integer.parseInt(Breadth) * Integer.parseInt(Length)));
       System.exit(0);

    Now My question is... How Do I make my code accept Decimal values. E.g. My Code should accept 10.02 as Length and 20.42 as Breadth and give the product a Decimal. How Do I do this???

    Appreciate the help.
    Last edited by GregBrannon; July 1st, 2014 at 08:02 AM. Reason: Fixed highlight tags.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help on Float Values

    Duplicate. Thread closed.

Similar Threads

  1. Replies: 2
    Last Post: October 26th, 2013, 09:56 AM
  2. Replies: 2
    Last Post: October 26th, 2013, 09:56 AM
  3. issues with a float
    By 2k. in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 30th, 2011, 12:03 PM
  4. Reading IEEE float values from files.
    By username9000 in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 30th, 2009, 12:56 PM
  5. How to convert float and double data types to binary?
    By rosh72851 in forum Java Theory & Questions
    Replies: 1
    Last Post: October 7th, 2008, 10:45 PM