Page 2 of 2 FirstFirst 12
Results 21 to 37 of 37
  1. #21
    RanLineR Guest

    Default

    import.java.io*
    import javax.swing.*;

    public class Activity1{
    public static void main(String args[])throws IOException{

    String ans = JOptionPane.showInputDialog("Enter an integer value:");
    int iVal = Integer.parseInt(ans);


    }
    }



    SIR IS THIS RIGHT?

  2. #22
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    You can ask questions, but your posts were looking like a "do this for me" thing.

    What you do is try it yourself, and if you hit a problem come here and post your problem and the code and any errors/exceptions you're getting.

  3. #23
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Quote Originally Posted by RanLineR View Post
    SIR IS THIS RIGHT?
    Does it work?

    (And you shouldn't use all caps, because that the forum equivalent of shouting)

  4. #24
    RanLineR Guest

    Default

    ahh okay...

  5. #25
    RanLineR Guest

    Default

    im like pounded in here.

  6. #26
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    It does seem that way.
    But you are making all the classic mistakes when it comes to trying to get help...:)

    Let's start again shall we?

    You've got this code:
    Java Code:
    import.java.io*
    import javax.swing.*;
    
    public class Activity1{
        public static void main(String args[])throws IOException {
            String ans = JOptionPane.showInputDialog("Enter an integer value:");
            int iVal = Integer.parseInt(ans);
        }
    }
    which will pop up a dialog and get an int from it (at least that what it looks like to me).

    So, does this compile and does it do what you want (ie get an int)?

  7. #27
    RanLineR Guest

    Default

    it compiles but it is error "exception in main.java lang" sorry if im lack of knowledge


    im so sorry im not pro >.<

  8. #28
    RanLineR Guest

    Default

    it lacks something wait ill try

  9. #29
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    When posting an exception you ought to give the full exception and the stack trace (that's the list that tends to come after the "Exception in..." line).

    We all had to start somewhere...some of us tend to forget that, especially 20-30 years down the line.
    :)

    Also, rather than double-posting (one post after the other) you can edit your post if you think of something else.

  10. #30
    RanLineR Guest

    Default

    lemme try. how sir?

  11. #31
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Just post whatever you're getting on the console/command line.

    How are you running this?

  12. #32
    RanLineR Guest

    Default

    what do you mean? im using JCreator.

  13. #33
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Well, there are several different IDEs (of which youare using one), as well as running it from the command line.

    I don't know JCreator, but presumably you can cut and past the output from running this program?

  14. #34
    RanLineR Guest

    Default

    oh man im weak in english can you please what specify what do you mean. Thanks for the help anyway even im just newbie.

  15. #35
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Quote Originally Posted by RanLineR View Post
    it compiles but it is error "exception in main.java lang" sorry if im lack of knowledge


    im so sorry im not pro >.<
    post your full error, there must be more information. also if you read back in your thread JosAh has mentioned using Scanner instead of JOptionPane here to get user input, which I agree with

    Scanning (The Java™ Tutorials > Essential Classes > Basic I/O)


    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

    you need to implement 6 methods as I see it

    1. int getAbsoluteValue(int value);
    2. double getSquareRootOfValue(int value);
    3. double getPowerOf2OfValue(int value);
    4. double getFloorOfValue(double value);
    5. double getCeilOfValue(double value);
    6. boolean areStringsEqual(String param1,String param2);
    Last edited by al_Marshy_1981; 10-16-2010 at 02:28 AM. Reason: further help

  16. #36
    luke is offline Member
    Join Date
    Sep 2010
    Posts
    62
    Rep Power
    0

    Default

    Quote Originally Posted by RanLineR View Post
    oh man im weak in english can you please what specify what do you mean. Thanks for the help anyway even im just newbie.
    As JosAH said try using Scanner. Something like

    Java Code:
    import java.util*;
    
    Scanner input = new Scanner();
    int value = input.nextInt();

  17. #37
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by RanLineR View Post
    Tolls said that i dont ask anymore. Thats why i stop.
    No, Tolls just said not to dump your homework here expecting others to do it. It's OK to ask questions.

Page 2 of 2 FirstFirst 12

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
  •