PDA

View Full Version : java help



VietBoyVS
04-25-2004, 11:47 PM
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.

chromate
04-26-2004, 06:30 AM
Do you mean JavaScript or Java?

Dan Grossman
05-01-2004, 12:20 AM
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

Westech
05-01-2004, 12:49 PM
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:



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