Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

# Java - Simple Loop Question

### #1 rhymin Posted 04 March 2013 - 05:34 PM

rhymin

Member

• Member
• 210 posts
Where I put "someTypeOfCalculation", I'm not exactly sure what to put there. You see, if the annual sales that one enters is < 96,000, they earn no commission...if the annual sales is between 96,000 and 120,000, they earn a 25% commission, and if the annual sales is above 120,000, they earn 31.25% commission.

I made an if-else-if statement before the loop code that performed these calculations separately, and now I really don't know what to do so it calculates and displays all of these correctly.

I can post the entire code if it would help.

```for(double counter = annualSales; counter <= annualSales * 1.5;
counter += 5000)
{
System.out.println("Total Sales: " + counter + "\tTotal "
+ "Compensation: " + someTypeOfCalculation);
}
```

• 0

### #2 Bismillah Posted 05 March 2013 - 09:57 AM

Bismillah

Member

• Member
• 514 posts
How is Compensation calculated? From Commission?
• 0

### #3 Bismillah Posted 05 March 2013 - 10:11 AM

Bismillah

Member

• Member
• 514 posts

A salesperson will earn a fixed monthly salary of \$4,000.00.
A salesperson will also receive a commission as a sales incentive. Commission is a percentage of the salesperson’s annual sales. The current commission is 20% of total sales.
The total annual compensation is the fixed salary plus the commission earned.

The Java application should meet these technical requirements:

The application should have at least one class, in addition to the application’s controlling class (a controlling class is where the main function resides).
There should be proper documentation is the source code.
The application should ask the user to enter annual sales, and it should display the total annual compensation.

Im not sure if this is what you want but this will work

```double AnnualSales = PUTANNUALSALESINPUTHERE;

double Compensationdue = (AnnualSales x 0.2);
//Compensation due is the AnnualSales divided by 20%

double TotalAnnualCompensation = (4000.00 + CompensationDue);

Systmem.out.Println("Well done, for this month you have earned: " + Compensationdue + " Compensation")
System.out.Println("In total you have earned: " + TotalAnnualCompensation);```

• 0

### #4 sari Posted 06 March 2013 - 09:18 AM

sari

• 21,805 posts
rhymin,

As I understand it, you're working on an assignment for school. I'd like to clarify something. Geeks to Go exists to help people, be it with computers, coding, malware, or understanding assignments. By those standards, we will provide help to you in understanding how Java works, but we will not provide the answers and coding for you, just help you to understand it. In return, I'd like to ask you to stop posting multiple topics about the same issue. You currently have 7 topics, primarily about Java looping. What I would recommend is that you pick one of the topics to continue with, rather than starting a new one every time you have a question. I'd also like you to work through as much as you can by yourself, so that your questions are not about the entire assignment, but just seeking clarification on a point you don't understand.

Sari
• 0

### #5 rhymin Posted 06 March 2013 - 06:02 PM

rhymin

Member

• Topic Starter
• Member
• 210 posts

As for the code, I do write it myself and ask for clarifications or hints on how to improve it, just like in this thread.

I in no way want other people to write my code for me as I won't learn anything from it.

Again, I apologize for multiple threads. That won't happen again.
• 0

### #6 rhymin Posted 06 March 2013 - 06:03 PM

rhymin

Member

• Topic Starter
• Member
• 210 posts
Bismillah, thank you for getting back to me. I just now saw this message so I am going to work on what you posted.

Thanks!
• 0

### #7 sari Posted 06 March 2013 - 06:16 PM

sari

• 21,805 posts

I in no way want other people to write my code for me as I won't learn anything from it.

That's exactly right! I just wanted to make sure you understand what type of help we're willing to offer with homework, and I hope that Java is starting to become clearer to you now.
• 0

### #8 rhymin Posted 06 March 2013 - 09:14 PM

rhymin

Member

• Topic Starter
• Member
• 210 posts
I've only been studying it for 3 1/2 weeks. I think what makes it so difficult in this class is that it's a 5 week accelerated course and my buddy took a regular 14 week course. I've been studying my @\$\$ off though and have learned a lot.

Thank you all for replying and helping me!
• 0

### #9 Bismillah Posted 08 March 2013 - 04:23 AM

Bismillah

Member

• Member
• 514 posts
I learnt Java by making simple programs then moving up to bigger ones, Google is your friend and will help you with many answers, another good place to look is websites such as Stack Overflow and the actual java dev pages.

Im assuming that you have learnt another programming language, try writing the program in pseudocode first before you jump in to netbeans and attempt to code the program, pseudocode will save you time in debugging and wondering why something isnt working.

Edited by Bismillah, 08 March 2013 - 04:24 AM.

• 0

### #10 rhymin Posted 08 March 2013 - 06:40 AM

rhymin

Member

• Topic Starter
• Member
• 210 posts
I have not learned another code but do know what psuedocoding is. Java was a requirement for my information technology degree even though I'm going for advanced networking. I'm still interested in learning Java well after my class is over, but I'm just not picking it up as quickly as I thought (it's hard lol).

• 0

### Similar Topics

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users