1. Member
Join Date
May 2015
Posts
3
Rep Power
0

## Help with Homework

I have the code built correctly I believe but it is still not looping. Can anyone help me please, I do not get this at all.

2. ## Re: Help with Homework

It's Monday, so no crystal balls are allowed in the building; show us the (relevant) code if you want to get help.

kind regards,

Jos

3. Member
Join Date
May 2015
Posts
3
Rep Power
0

## Re: Help with Homework

Here is what I have so far. I have dissected this code a million times and this is what I am starting over with now. How do I get to loop to 100K, 105K,110K etc?

import javax.swing.*;
import java.text.DecimalFormat;
import java.util.Scanner; //Use for input from comamndline.
import java.text.NumberFormat; // Use to control decimal output
import salescommission.Compensation;
public class Sales {

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
DecimalFormat dol = new DecimalFormat ("#,###,##0.00");
Scanner input = new Scanner (System.in); //object to read commandline input
System.out.print("Please enter the salesperson's total sales: "); // prompt the user to enter sales on the commandline
Compensation c = new Compensation(); //create object form the Compensation class
c.setSalary(35000); // initialize the Salary to 35000
c.setCommission(8.0); // initialize the commission to 8 percent
c.setSales(input.nextDouble()); //read the sales form the commandline
System.out.println("Salesperson's total compensation: \$" + dol.format(c.getCompensation())); //print results of annual compensation formatted as \$

int sum = 100000;
int salesAmount = 100000;
for (int i = salesAmount; i <= salesAmount*1.5; i=+5000)
sum += i;
System.out.println(sum);

}
}

5. ## Re: Help with Homework

For starrters:

1) put [code] ... [/code] tags around your code for readabilty; (that's what Darryl was trying to say to you)
2) I don't see a loop anywhere in your code (a for loop maybe?)

kind regards,

Jos

6. Member
Join Date
May 2015
Location
Netherlands
Posts
39
Rep Power
0

## Re: Help with Homework

Java Code:
```int sum = 100000;
int salesAmount = 100000;
for (int i = salesAmount; i <= salesAmount*1.5; i=+5000)
sum += i;
System.out.println(sum);```
shouldn't it be
Java Code:
```int sum = 100000;
int salesAmount = 100000;
for (int i = salesAmount; i <= salesAmount*1.5; i=+5000){
sum += i;
System.out.println(sum);
}```
the curly brackets and spaces before the content of the loop are basically there to say 'we are part of this loop and have no connection to anything outside of it' right?
so it's important to have them there
Last edited by Artemia; 05-25-2015 at 10:32 PM.

7. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
14

## Re: Help with Homework

That only depends on whether the OP wanted the final sum or intermediate sums. In any event, that was not the problem. The loop is infinite because i never changes. The update of i in the for loop is incorrect. The OP keeps setting i to 5000. It should be i += 5000, not i =+5000;

Regards,
Jim

8. Member
Join Date
May 2015
Posts
3
Rep Power
0

9. Just a guy
Join Date
Jun 2013
Location
Netherlands
Posts
5,114
Rep Power
12

## Re: Help with Homework

Originally Posted by JosAH
It's Monday, so no crystal balls are allowed in the building; show us the (relevant) code if you want to get help.
Only on Monday? You should have a word with the doorman then as he confiscates them on any day of the week.

10. ## Re: Help with Homework

Originally Posted by gimbal2
Only on Monday? You should have a word with the doorman then as he confiscates them on any day of the week.
Erm,yes he owns a second hand crystal ball shop downtown; except for a few scratches here and there, they're fine balls; that's were I got mine recently ...

kindest regards,

Jos

11. Just a guy
Join Date
Jun 2013
Location
Netherlands
Posts
5,114
Rep Power
12

## Re: Help with Homework

I thought I recognized that particular shade of pink. Well have fun with it.

12. ## Re: Help with Homework

They look red to me, all three of them

#### Posting Permissions

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