Results 1 to 4 of 4

Thread: java help

  1. #1
    Junior Registered VietBoyVS's Avatar
    Join Date
    Jan 2004
    Posts
    5

    java help

    Hi guys & gals,

    Is there a way in Java that I can convert a double type number such as 3.1111111111222 to only two decimal places? So it would be as 3.11 only?

    Another question is how to do Stop a method from running in Java Code?

    For example.. I'm doing a loop.. and a user input a 'char' type.
    If it's match.. it stop excute.. other while it keeps going.

    I know have to use input, and if and else statement.

    Which I already did.. But I need a method to stop from running..

    Please help...

    Thank you so much.

  2. #2
    Senior Member chromate's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    2,348
    Do you mean JavaScript or Java?

  3. #3
    Registered
    Join Date
    Mar 2004
    Location
    Philadelphia, PA
    Posts
    106

    Re: java help

    Originally posted by VietBoyVS
    Is there a way in Java that I can convert a double type number such as 3.1111111111222 to only two decimal places? So it would be as 3.11 only?
    Rounding a double in Java:

    http://www.rgagnon.com/javadetails/java-0016.html

  4. #4
    Chronic Entrepreneur
    Join Date
    Nov 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    1,112

    Re: java help

    Originally posted by VietBoyVS
    Another question is how to do Stop a method from running in Java Code?

    For example.. I'm doing a loop.. and a user input a 'char' type.
    If it's match.. it stop excute.. other while it keeps going.

    I know have to use input, and if and else statement.

    Which I already did.. But I need a method to stop from running..
    Try using a while loop. Something like this:

    Code:
    while (char1 != char2) {
       //prompt user and get input as char2
    }

Similar Threads

  1. Java Script
    By Browneyes105 in forum HTML, CSS, Layout, and Design
    Replies: 8
    Last Post: 01-22-2004, 05:18 AM
  2. How come (javascripT)
    By Johan H in forum Search Engine Optimization
    Replies: 4
    Last Post: 10-01-2003, 06:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •