hi
i am practicing this program here and i am outputting zero. trying my best where is the error
here is the code

double fed_tax = 0, state_tax = 0,  hrswrk, payrate=0, gross_salary = 0;
        double hrlyrate=0;

        System.out.println("hi please enter your first name");
        String firstname = userinput.next();

        System.out.println("hi please enter your last name");
        String lastname = userinput.next();

        System.out.println("hi please enter the number of hours work");
        hrswrk = userinput.nextDouble();


        double hrs = (hrlyrate * hrswrk);
        hrs = (payrate * hrswrk);
        gross_salary = (fed_tax * 0.20) + gross_salary;
        gross_salary = (state_tax  * 0.9) + gross_salary;
        double total_deduction = (fed_tax + state_tax);
        double net_salary = (gross_salary - total_deduction);

        System.out.println("the employee name is "+firstname+lastname);
        System.out.println("the total deduction is "+total_deduction);
        System.out.println("the gross pay is "+gross_salary);
        System.out.println("the net salary is "+net_salary);

You create a range of variables:
double fed_tax = 0, state_tax = 0, hrswrk, payrate=0, gross_salary = 0; double hrlyrate=0;
But never change their values. For example, you get the user to enter a value for hrswrk but then times that by hrlyrate.

0 x anything = 0. All of the other calculations are similarly zeros get added and multipled together.

i removed the zero from fed_tax, state_tax, gross_salary, payrate and hrly rate and i get syntax errors, how do i correct this

Hi

THis is almost identical to the problem you had six months ago
https://www.daniweb.com/programming/software-development/threads/498758/tell-me-what-is-wrong-with-this
and that was almost identical to an even earlier one a year ago
https://www.daniweb.com/programming/software-development/threads/489301/payroll
But you seem to be learning nothing, and have made no progress. Your persistence is admirable, but I am afraid that you are wasting your time. Just look back at the 62 threads you have started and see how the same issues come up over and over again.
I don't want to be mean, but I really think that programming is not your thing, and that you should be looking for another field that would suit your talents better.
Sorry
JC

hi james
i am sorry you feel this way about me and i am also sorry if i dont come up to par with you maybe this did cross my mind in giving but i have reached to far to give up.

It's a very difficult decision, and I wish you all the best whatever route you chose to take.
There's no shame in this - we all have out inbuilt talents and limitations (eg I could never be a long-distance runner or a boxer or a painter or a singer, no matter how hard I tried - I just don't have enough of the necessary physical or mental traits). The smart thing is to learn what your talents are and go in a direction that makes best use of them.
I wish you the best of good luck
J

Divinity: nobody expects you to build up to anyones level but your own, but the question you must ask yourself:

"If I still make (almost) the exact same errors as I did a year ago and still not manage to get any further toward a solution then I did at that time ... did I really reach as far as I did?"

From now on, try this.. When you get an issue, don't immediately post a new thread here, but check your previous threads.
If the problem was the same, chances are, so is the solution.
So, try to fix the problem by going over the previous replies. If the problem is similar or identical, and you can't solve it by investigating the previous fixes, or if you have to go back to your previous threads each time you write a new piece of code like this to filter out the errors, I would recommend you to follow James' suggestion, since if that's the case, you:

  1. Have a very limited knowledge of the basics, while, since you started over a year ago, one could expect your basic knowledge to have increased by now
  2. Have trouble remembering past issues and how-to-fix-it, which is, I'm afraid something very common and utmost important.

Choosing a different path and keeping programming as just a hobby is far from a shame.
Think of it like this: two guys want to keep a running contest, about 200m (as the crow flies) spurt.

In the middle of this 200m, however, there is a brick wall. Do you prefer to be the guy who might run slower, but after bumping his head against said wall once, runs around it to reach the finish, or would you like to be seen as the more persistent one, that fails to see a blocking issue on his path?
He may be the fastest of the two, but bumping his head over and over and over on that wall, will not help him get to that finish line.

Just like James, I'd say, best of luck, just make sure you're (subconciously) not countering it yourself.

hi
Don't let anybody tell you that you can't do something when the Bible says:
You can do all things through Christ....Phillippians 4:13

Hello,
I can see what is causing your problem but just telling you will not help you solve this in the future. What I do when a piece of code is not giving me what I expect is to print the variables before and after any calculation or changes to the variables. At line 13 put in some print statements to see what values you are passing to the code at that point. Something like this but for every variable involved:

System.out.println("hrlyrate = "+hrlyrate);
System.out.println("hrswrk = "+hrswrk);
System.out.println("payrate = "+payrate);

I think you will see what is causing your problem then.

ok thank u very much rch1231

@rch1231 : actually, in the very first reply, hericles already told him exactly what the problem was.

hi stultuske
i have read hericles and already fix it and even though i still have a few kinks to irons out, i haven;t got round in fixing it as yet since i have other assignment to do so i rest it down for a while and stultusk,

I am not a boy or man, i am a female, not a male okay

Hi divinity,
You read my reply but I don't think you understood it. The issue wasn't that the variables were zero to begin with. It was that you never changed them from zero to anything else.
You get the hrswrk from user input but that is all. If you intend to use those variables mathmatically they need to be actual numbers (zero is a valid value but you need to realise that multiplying anything by zero gives zero as the result).

divinity02 : I don't consider your gender to be a factor that decides whether or not you are/can be a good developer.
If you felt offended by me referring to you as 'him', my apologies, it's just that the username 'divinity02' doesn't really say anything about your gender, so mistakes are bound to happen.

my reply was actually to rch1231, who said:

I can see what is causing your problem but just telling you will not help you solve this in the future
while actually it was already told to you in the first reply.

hericles i do understand what u were saying it is just that i got it to work partially but i have rest it down for a while as i said because of other assignment and exams coming up and stultuske i am not offended by what u said about my gender, i actually was laughing, i know it was an honest mistakes, everyone do makes mistakes from time to time. even i do made mistakes. so dont worry up yourself.

hi james, stultuske, hericles and rch1231
you all think that I should give up programming, well I am not giving up. and i just want you guys to know the program above that I having some problems figure out, well let me tell you this, i have just figure it out and i have seen where my mistakes was, so the program give me the output that i was looking for so and as the bible says:

Don't let anybody tell you that you can't do something when the Bible says:
You can do all things through Christ....Phillippians 4:13

with perservence and a little of believing in myself, i figure it out. thanks for the help, you have just let me know that when someone tell you that u cant do something, it shows them that you can do it.

To be fair, nobody said you couldn't do it. We just suggested that your time may be better spent doing something that fits better with your talents.
But well done anyway.
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.