1. Member
Join Date
Feb 2013
Posts
32
Rep Power
0

## Java looping?

I am changing all of my posts bc someone in my class copied and pasted my entire code last time...cheating off of hours of work I put in.
Last edited by rhym1n; 03-04-2013 at 06:32 AM.

2. Member
Join Date
Feb 2013
Posts
32
Rep Power
0

## Re: Java looping?

Last edited by rhym1n; 03-04-2013 at 06:31 AM.

3. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,504
Rep Power
9

## Re: Java looping?

I don't believe you want a loop but an if statement. Your while loop is governed by the following test:

Java Code:
`annualSales >= salesIncentCalc || annualSales <= salesTarget`
But none of those are updated within the loop so once it enters the loop it will loop forever.

Jim

4. Member
Join Date
Feb 2013
Posts
32
Rep Power
0

## Re: Java looping?

Thank you for that. How would I write it so it knows it's between 96,000 (salesIncentCalc) and 120,000 (salesTarget)?

5. Member
Join Date
Feb 2013
Posts
32
Rep Power
0

## Re: Java looping?

Last edited by rhym1n; 03-04-2013 at 06:31 AM.

6. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,504
Rep Power
9

## Re: Java looping?

Well, assuming I understand what you are trying to do you would need three condition tests:

Java Code:
```if (AnnualSales >= 96000 && AnnualSales <= 120000) { // between the two inclusive

// do something at 25%

} else if (AnnualSales < 96000) {

// do something else at 0%

} else { // at this point AnnualSales must be > 120000 so

// do something here at 31.25%

}```
Regards,
Jim

7. Member
Join Date
Feb 2013
Posts
32
Rep Power
0

## Re: Java looping?

asdf
Last edited by rhym1n; 03-04-2013 at 06:31 AM.

8. Member
Join Date
Feb 2013
Posts
32
Rep Power
0

## Re: Java looping?

Nevermind, I figured it out thanks to your advice. I seriously couldn't have done it if it wasn't for you. Thank you so much for taking the time to help me.

Very appreciated :)

9. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,504
Rep Power
9

## Re: Java looping?

That is not advisable. I am not a moderator but it is my experience that it is not permitted to delete your posts. They will probably be restored. It is my opinion that any code posted in this forum becomes public domain and may be used by anyone. After all, this is a forum for learning. When it comes to homework and other related assignments, honor codes prevail.

Regards,
Jim

#### Posting Permissions

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