Results 1 to 5 of 5
  1. #1
    MomenT is offline Member
    Join Date
    Sep 2008
    Posts
    25
    Rep Power
    0

    Default ForLoop statement problem

    Hey guys.. I have a problem my program does not loop once as i wanted it just loops as many as possible.. what went wrong?


    class ForLoop
    {
    public static void main (String [] args)
    {
    int i;
    int s = 500;
    for (i=1; s>=500; i--)
    {
    System.out.println ("You are entitled 10% discount");
    }
    }
    }

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Java Code:
    for (i=1; s>=500; i--)
    {
        System.out.println ("You are entitled 10% discount");
    }
    In the above code, which variable is being checked, and which variable is being initialised and decremented?

    Don't you think they should be the same?

  3. #3
    MomenT is offline Member
    Join Date
    Sep 2008
    Posts
    25
    Rep Power
    0

    Default

    oh.. let me try it..

  4. #4
    MomenT is offline Member
    Join Date
    Sep 2008
    Posts
    25
    Rep Power
    0

    Default

    nothing came out when i execute it.

  5. #5
    MomenT is offline Member
    Join Date
    Sep 2008
    Posts
    25
    Rep Power
    0

Similar Threads

  1. Please help me with this Problem Statement
    By KMS in forum New To Java
    Replies: 1
    Last Post: 09-22-2008, 09:44 PM
  2. Beginner's Problem on Loop/If statement
    By obdi in forum New To Java
    Replies: 2
    Last Post: 07-07-2008, 02:41 AM
  3. Problem with a switch statement in Java
    By baltimore in forum New To Java
    Replies: 2
    Last Post: 08-02-2007, 05:43 AM
  4. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 05:45 PM
  5. Help with ForLoop
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 07:24 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
  •