July 29th, 2003, 10:38 AM
Java Help, Plase...
I am having the following problem in Java simple program .
the question is:
write a console program to declare and initialize a double variable with some value such as 1234.5678, then retrieve the integral part of the value and store it in the variable of type long, and the first four digits of the fractionL part and store in the integer type short.
Display the value of the double variable by outputing two values stored as integers.
I have gone through the class Math, and seen all the methods, abut i think there is some other way of doing it. Please help me out.
July 29th, 2003, 11:58 AM
Well there are more than one way to do it. I won't give u the details because I guess this is some sort of exercise. Since u have gone thru the class Math, now it's time to go thru the class Double (java.lang.Double). Good luck!
I have gone through the class Math, and seen all the methods, abut i think there is some other way of doing it.
Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds
July 29th, 2003, 12:13 PM
If you didn't know, to look at the javadoc for the classes go to:
Find Double and look at it's methods. Here is a little snippet to get you going. I think this is the easy part anyway. The rest of it should be the challenge.
Try this out and see what it does, the try to figure out the rest of it. Good luck!
double i = 123.456;
Double d = new Double(i);
long x = d.longValue();
\"When you say best friends, it means friends forever\" Brand New
\"Best friends means I pulled the trigger
Best friends means you get what you deserve\" Taking Back Sunday