Results 1 to 5 of 5
Thread: ForLoop statement problem
- 10-01-2008, 12:21 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 25
- Rep Power
- 0
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");
}
}
}
- 10-01-2008, 12:27 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
In the above code, which variable is being checked, and which variable is being initialised and decremented?Java Code:for (i=1; s>=500; i--) { System.out.println ("You are entitled 10% discount"); }
Don't you think they should be the same?
- 10-01-2008, 12:49 PM #3
Member
- Join Date
- Sep 2008
- Posts
- 25
- Rep Power
- 0
oh.. let me try it..
- 10-01-2008, 12:51 PM #4
Member
- Join Date
- Sep 2008
- Posts
- 25
- Rep Power
- 0
nothing came out when i execute it.
- 10-01-2008, 01:01 PM #5
Member
- Join Date
- Sep 2008
- Posts
- 25
- Rep Power
- 0
Similar Threads
-
Please help me with this Problem Statement
By KMS in forum New To JavaReplies: 1Last Post: 09-22-2008, 08:44 PM -
Beginner's Problem on Loop/If statement
By obdi in forum New To JavaReplies: 2Last Post: 07-07-2008, 01:41 AM -
Problem with a switch statement in Java
By baltimore in forum New To JavaReplies: 2Last Post: 08-02-2007, 04:43 AM -
Statement or Prepared Statement ?
By paty in forum JDBCReplies: 3Last Post: 08-01-2007, 04:45 PM -
Help with ForLoop
By Albert in forum New To JavaReplies: 1Last Post: 07-05-2007, 06:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks