Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Why raiseSalary equation can't work? empolyee.java

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Why raiseSalary equation can't work? empolyee.java

    why in raiseSalary(): salary *= (100 + percent) / 100 won't work?

     
    // why salary *= (100+percent)/100 wont work? 	
         }public void raiseSalary(int percent){
    		salary = salary*(100+percent)/100;
    Last edited by kennylty; March 7th, 2014 at 06:57 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,135
    My Mood
    Mellow
    Thanks
    187
    Thanked 660 Times in 647 Posts

    Default Re: Why raiseSalary equation can't work? empolyee.java

    Simplify the equation in the method to see if you can answer your own question. When you've obtained the simplified equation, don't forget to apply the rules of 'integer math.'

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why raiseSalary equation can't work? empolyee.java

    Quote Originally Posted by GregBrannon View Post
    Simplify the equation in the method to see if you can answer your own question. When you've obtained the simplified equation, don't forget to apply the rules of 'integer math.'
    I am able to do it by adding a (double). thanks for the help.

         }public void raiseSalary(int percent){
    		salary *= (double)(100+percent)/100;

Similar Threads

  1. Replies: 3
    Last Post: January 16th, 2014, 05:00 PM
  2. Equation
    By musa_danjuma in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 10th, 2013, 09:22 PM
  3. Replies: 1
    Last Post: November 6th, 2011, 08:48 PM
  4. Java Equation correct syntax
    By macko in forum What's Wrong With My Code?
    Replies: 18
    Last Post: November 4th, 2011, 11:16 PM
  5. Help with Quadratic forumla equation in java please.
    By taylor6132 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 27th, 2010, 07:27 PM