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 3 of 3

Thread: ParseDouble.

  1. #1
    Member
    Join Date
    Oct 2013
    Posts
    31
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default ParseDouble.

    Hello I have a couple of questions. I'm a newbie at Java programming and I have a project due tomorrow and because I cannot figure out how to do these things it's hindering my ability to complete my project.
    First question is : How would i ParseDouble a Scanner class(not sure if i said that correctly)? And also how would I divide a user input rate by 12 and also 100? An example would be
    double rate = (User input) / 12 /100;
    System.out.print ("Enter the rate: ");
    rate = parsedouble(how would i finish this part of the code)?

    Any help would be appreciated with the code to do so!


  2. #2
    Member
    Join Date
    Jul 2013
    Location
    Franklin, TN
    Posts
    48
    Thanks
    3
    Thanked 4 Times in 4 Posts

    Default Re: ParseDouble.

    To parse a double from the user you can use the Scanner class' nextDouble() method. You can use it to directly initialize a variable as you declare it. This scanner class can be used to read all types input from the user and store them in memory.

    More info: Scanner class - Java

    // Assuming a scanner object has been created, 'scanner'
    System.out.print("Input is: ");
    double input = scanner.nextDouble();

  3. The Following User Says Thank You to AlexHail For This Useful Post:

    Ancharius (October 21st, 2013)

  4. #3
    Member
    Join Date
    Oct 2013
    Posts
    31
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: ParseDouble.

    Thanks so much!

Tags for this Thread