Results 1 to 17 of 17
  1. #1
    KAM0002 is offline Member
    Join Date
    Dec 2010
    Posts
    15
    Rep Power
    0

    Default calculating taxes in java

    Solved a lot of these problems. I have another post for help with one final thing, so if you'd like, check out that post to help me with a loop problem.
    Last edited by KAM0002; 12-07-2010 at 08:11 PM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Then initialize the variable first of all, before use it. If you've look at the complete error message you can track the location easily.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    When dealing with currencies and financial things it is generally better to use BigDecimal and not something float-based (like double). That doesn't answer your question, but I thought I'd give you that little pointer.

  4. #4
    demonick is offline Member
    Join Date
    Dec 2010
    Posts
    27
    Rep Power
    0

    Default

    Could it be that HorlyWage is greater than taxrate_10 most of the times? Cause that could be a logical explanation why it only prints out the employees name. The program never enters the first while loop where MonthlySalary is first initialized.
    Last edited by demonick; 12-07-2010 at 12:05 PM.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by KAM0002 View Post
    Okay, I have fixed that error, but why am I not getting any output except the employee name?
    Did you fix it and run the code?

  6. #6
    KAM0002 is offline Member
    Join Date
    Dec 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    When dealing with currencies and financial things it is generally better to use BigDecimal and not something float-based (like double). That doesn't answer your question, but I thought I'd give you that little pointer.
    This is for a class, and we have only learned double.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Ah, should have guessed.
    Sorry!
    :)

  8. #8
    KAM0002 is offline Member
    Join Date
    Dec 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by demonick View Post
    Could it be that HorlyWage is greater than taxrate_10 most of the times? Cause that could be a logical explanation why it only prints out the employees name. The program never enters the first while loop where MonthlySalary is first initialized.
    If I need the program to calculate MonthlySalary no matter what the HourlyWage is, then where would I be able to put MonthlySalary so it would initialize each time?

  9. #9
    KAM0002 is offline Member
    Join Date
    Dec 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Did you fix it and run the code?
    I did. I am only getting the EmployeeName output.

  10. #10
    KAM0002 is offline Member
    Join Date
    Dec 2010
    Posts
    15
    Rep Power
    0

    Default

    Also, when I enter an amount that does give me an output, the loop just keeps going. How do I make it only run once?

  11. #11
    demonick is offline Member
    Join Date
    Dec 2010
    Posts
    27
    Rep Power
    0

    Default

    Quote Originally Posted by KAM0002 View Post
    If I need the program to calculate MonthlySalary no matter what the HourlyWage is, then where would I be able to put MonthlySalary so it would initialize each time?
    You should check the value of HourlyWage, and if you don't need it, erase the while block which checks HourlyWage and see if the program outputs different information.

  12. #12
    demonick is offline Member
    Join Date
    Dec 2010
    Posts
    27
    Rep Power
    0

    Default

    Check the braces, if every opening brace has its closing brace.

  13. #13
    Bertstar is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default

    There are two threads for this one problem are we posting in this one?

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Bertstar View Post
    There are two threads for this one problem are we posting in this one?
    If you found the same question in multiple threads, comment with the URL. Then we can close one of them. :) Because multiple posts are not allowed.

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    KAM0002, do not edit(delete) the original question once you found the answer. Whole thread going to be a mess. And also if you have a new question, which is not related with the existing threads post by you, please start a new thread in an appropriate sub-forum.

  16. #16
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Quote Originally Posted by KAM0002 View Post
    Solved a lot of these problems. I have another post for help with one final thing, so if you'd like, check out that post to help me with a loop problem.
    Nope. Learn the difference between a forum and a helpdesk first.

    db

  17. #17
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. need help with calculating something
    By mikec420 in forum New To Java
    Replies: 13
    Last Post: 09-29-2011, 10:14 PM
  2. calculating the hypotenuse
    By Latanyar in forum New To Java
    Replies: 6
    Last Post: 10-12-2010, 10:20 AM
  3. calculating exponents
    By GPB in forum New To Java
    Replies: 2
    Last Post: 03-21-2010, 12:44 PM
  4. calculating with dates
    By hannes in forum New To Java
    Replies: 1
    Last Post: 01-14-2010, 09:22 PM
  5. [SOLVED] Calculating Std. Deviation using Java
    By random0munky in forum New To Java
    Replies: 1
    Last Post: 12-12-2008, 10:24 AM

Posting Permissions

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