Page 1 of 2 12 LastLast
Results 1 to 20 of 37
  1. #1
    RanLineR Guest

    Unhappy 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{

    BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in));

    what next?? thanks~!

  2. #2
    RanLineR Guest

    Default

    and somebody said that i can work easier using JOption?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    No of course you can with JOption.

    But you've to deals with correct conversions, JOption returns an object of string.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  5. #5
    RanLineR Guest

    Default

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

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Java Code:
    String ans = JOptionPane.showInputDialog("Enter an integer value:");
    int iVal = Integer.parseInt(ans);
    Try to understand above.

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,539
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by RanLineR View Post
    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

  8. #8
    RanLineR Guest

    Default

    sir can you do the the absolute value of" +x+" is " +result); ?

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default

    Please don't ask people to do your homework for you.

  10. #10
    RanLineR Guest

    Default

    im just asking how to use that code because im new to it.

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Tolls View Post
    Please don't ask people to do your homework for you.
    Agreed. I've already give a hint with the code, and I asked OP to try to understand it. Seems it wont that way.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by RanLineR View Post
    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?

  13. #13
    RanLineR Guest

    Default

    okay thanks by the way.much appreciated =)

  14. #14
    RanLineR Guest

    Default

    yep a little. as i said im a begginer.

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    If you don't want to learn from what we say, I'm sure it's not encourage us to helping you out.

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by RanLineR View Post
    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. ;)

  17. #17
    RanLineR Guest

    Default

    what do you mean sir?

  18. #18
    RanLineR Guest

    Default

    yes sir =))))

  19. #19
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    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.

  20. #20
    RanLineR Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  2. Working with Methods
    By besweeet in forum New To Java
    Replies: 5
    Last Post: 03-25-2010, 05:33 PM
  3. Replies: 4
    Last Post: 04-03-2009, 06:36 AM
  4. Replies: 8
    Last Post: 05-28-2008, 07:00 AM
  5. Static methods - not working
    By Echilon in forum New To Java
    Replies: 2
    Last Post: 12-21-2007, 01:31 PM

Posting Permissions

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