Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Java - Simple Loop Question


  • Please log in to reply

#1
rhymin

rhymin

    Member

  • Member
  • PipPipPip
  • 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

Advertisements


#2
Bismillah

Bismillah

    Member

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

#3
Bismillah

Bismillah

    Member

  • Member
  • PipPipPip
  • 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

sari

    GeekU Admin

  • Community Leader
  • 21,806 posts
  • MVP
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.

Thank you for your cooperation,

Sari
  • 0

#5
rhymin

rhymin

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 210 posts
Sorry about posting multiple topics.

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

rhymin

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 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

sari

    GeekU Admin

  • Community Leader
  • 21,806 posts
  • MVP

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

rhymin

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 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

Bismillah

    Member

  • Member
  • PipPipPip
  • 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

rhymin

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 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).

Thank you very much for your advice.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP