Results 1 to 3 of 3
  1. #1
    javaguy2 is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default What do the following codes do?

    do {
    sum+=number;
    number ++;
    }while (sum<=10000);

    ----------------
    for this one below I need to know why it would not work as well as a while loop

    do{
    age=integer.parseInt{
    JOptionPane.showInputDialog(null, "Enter your age between 0 and 130."

    if (age<0 || age>130){
    JOptionPane.showMessageDialog(nul', "An Invalid age was entered. Try again."); }
    }while
    (age <0 || age > 130);


    ---------------
    there might be slight errors but I need to knows ASAP. Thanks in advance.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    Did you compile and run the code? What do YOU think they do? Suggested Reading: How To Ask Questions The Smart Way

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Welcome to the forum.

    To correct typos and other errors of syntax, and to observe program behaviour you will need to write a complete Java program, compile and run it.

    For the examples you posted it might be as simple as

    Java Code:
    class Test {
        public static void main(String[] args) {
            // paste the code here
        }
    }

    The compiler will help you identify any errors (including missing import statements). If you can't understand a compiler message, post both the code and the complete compiler message.

    Once it compiles without error you can run it. This will lead to one of three situations:

    (1) There might be a run time error. If you can't understand the error message, again post both the code and the complete error message along with the stack trace that is produced.

    (2) Something happens, but you can't understand why. In this case post the code and describe the actual behaviour. If you thought something else would happen (or desired that something else happen), describe that other behaviour as well.

    (3) Something happens and you understand why. In this fortunate case you are done.

    ---------------------------

    I need to know why it would not work...

    Most people will want to know what "work" means here. In other words they will need to know what the intended behaviour is. (Basically this is a variant of case (2) above.)

    ---------------------------

    Further good information is to be had at the smart questions faq.

    Good luck!

Similar Threads

  1. How do I integrate these two codes?
    By Isong in forum AWT / Swing
    Replies: 3
    Last Post: 11-03-2010, 02:44 AM
  2. two short codes
    By Libertyman in forum New To Java
    Replies: 7
    Last Post: 06-21-2010, 03:22 PM
  3. java codes
    By Balajee in forum AWT / Swing
    Replies: 1
    Last Post: 09-30-2008, 05:04 PM
  4. Assistant on my codes. SOS!!
    By sya1912 in forum Java Applets
    Replies: 16
    Last Post: 09-01-2008, 02:23 PM
  5. What's wrong with my codes?
    By ayoood in forum New To Java
    Replies: 16
    Last Post: 09-01-2008, 03:57 AM

Posting Permissions

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