# Working with Methods Can anyone help?

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• 10-15-2010, 07:19 AM
RanLineR
Working with Methods Can anyone help?
Activity3 working with methods

Sample

Enter an integer value: -9
Enter and integer value: 2
Enter a double value: 3.8
Enter first string : Anna
Enter second string : anna

The Absolute value of -9 is 9
The square root of 9 is 3.0
9 raise to 2 is equivalent to 81.0
The floor value of 3.58 is 3.0
The ceil value of 3.58 is 4.0
Anna is Equivalent to anna

this sample output needs to be the same with my work.

Sample:

int x =-9
result = Math.abs(x);

system.out.println("the absolute value of" +x+" is " +result);

this is what hint they give me.
i dont really understand what will i do in order to get the method.
:(

import java.io.*;
public class Activity4{
public static void main (String args[])throws IOException{

what next?? thanks~!
• 10-15-2010, 07:21 AM
RanLineR
and somebody said that i can work easier using JOption?
• 10-15-2010, 08:01 AM
Eranga
No of course you can with JOption.

But you've to deals with correct conversions, JOption returns an object of string.
• 10-15-2010, 08:01 AM
Eranga
Did you try anything with JOption, show it here if so?
• 10-15-2010, 09:14 AM
RanLineR
they said JOption is much easier to use, could you give me some sample?
• 10-15-2010, 09:22 AM
Eranga
Code:

``` String ans = JOptionPane.showInputDialog("Enter an integer value:"); int iVal = Integer.parseInt(ans);```
Try to understand above.
• 10-15-2010, 09:35 AM
JosAH
Quote:

Originally Posted by RanLineR
they said JOption is much easier to use, could you give me some sample?

A Scanner is even easier to use. Read the API documentation.

kind regards,

Jos
• 10-15-2010, 09:38 AM
RanLineR
sir can you do the the absolute value of" +x+" is " +result); ?
• 10-15-2010, 09:52 AM
Tolls
• 10-15-2010, 10:12 AM
RanLineR
im just asking how to use that code because im new to it.
• 10-15-2010, 10:14 AM
Eranga
Quote:

Originally Posted by Tolls

Agreed. I've already give a hint with the code, and I asked OP to try to understand it. Seems it wont that way.
• 10-15-2010, 10:15 AM
Eranga
Quote:

Originally Posted by RanLineR
im just asking how to use that code because im new to it.

Do you have an idea about the code segment I've post earlier?
• 10-15-2010, 10:15 AM
RanLineR
okay thanks by the way.much appreciated =)
• 10-15-2010, 10:17 AM
RanLineR
yep a little. as i said im a begginer.
• 10-15-2010, 10:18 AM
Eranga
If you don't want to learn from what we say, I'm sure it's not encourage us to helping you out.
• 10-15-2010, 10:20 AM
Eranga
Quote:

Originally Posted by RanLineR
yep a little. as i said im a begginer.

little means that you don't have fully understand something. Why don't you try to clarify those things first of all. Keep in mind lol, that's the way to learn. You must explore the world, and get the experience your self. ;)
• 10-15-2010, 10:21 AM
RanLineR
what do you mean sir?
• 10-15-2010, 10:23 AM
RanLineR
yes sir =))))
• 10-15-2010, 10:31 AM
Eranga
You ask a question here, and we all comment on you. Actually I gave you a simple code segments, and I ask you to try to understand it. Why I'm said that is, without experimenting something ourselves we can't learn a lot. Experience make a big difference. :)

What you've done is without doing that you ask another question. That's not good.
• 10-15-2010, 10:49 AM
RanLineR
Tolls said that i dont ask anymore. Thats why i stop.
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last