Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
The problem statement, all variables and given/known data:
) Your mission is to create an awk file that will report employee name, state, gross pay, taxes, and netpay in a specific format. The input file has the following fields:Name
State
Pay Rate
Hours Worked
Overtime Hours
There is math involved. The pay rate is the hourly pay rate � different for each employee. Overtime
hours are paid at 1.5 times base rate ((OT Hours * 1.5) Pay Rate). Gross Pay = (Hours Worked +
(Overtime Hours * 1.5)) * Pay Rate. Taxes are computed at 8% (0.08) for State = MO and 7% for State
= KS. Net Pay = Gross Pay - Taxes
The input file is: /home/faculty/hbecker3/projects/p5/payroll
The output should look like the following:
Name State
------------ --
Sam Smith MO
Gross Pay: $1690
Taxes: $135.2
Net Pay: $1554.8
(Formatting's a bit off but it needs to be aligned)
[/FONT]
Send me the link to your awk file (I will run it with the awk -f command).
Relevant commands, code, scripts, algorithms:
None, just needs to be in an awk format.
The attempts at a solution (include all code and scripts):
Well what we appreciate here also is when you submit your code, that you give the output produced, and eventually your comments on it explaining what you think happened, or what you cant achieve or do not understand
We are not going to give you the solution but more, clues or help you get there...
Comments: I think what happened is either my calculations aren't properly formatted, or the printf can't get the information correctly.
You may want to put a comments section in the template then, just as added help. I appreciate any help I can get. And If I need to reformat my post let me know
The � is a wrong double quote (coming from Microsoft Word?) you need to use " .
The general format in the mid section is :
condition { action }
so
{NR > 1}
makes no sense, since it is a condition, not an action
Also, in the BEGIN {} section, NR is always 0
Taxes = {MO|KS , .08|.07}
I don't know what you are doing here. If it is a string assignment then you need to use double quotes..
It is good practice to properly indent to improve readability, but also so you can easily see if the format is correct and the right number of curly braces have been used.
Look for the difference between BEGIN, END and middle section...
It's coming from the email i'm passing back and forth from my professor so yes the '' should be ".
Ah, ok that makes sense with NR = 0 during the BEGIN section since that occurs before the function. Taxes is supposed to put in .08 if in MO or .07 in KS, do i need to make it an if else statement or can i just include that in the block with " ?
It is a bit difficult to comment on an incomplete script without any input samples, and the error msgs missing as well as some indicators where you are stuck. Which is what vbe tried to convey, I think.
A few observations on your script in post#5, as there are syntactical errors, plus semantical / logical / mathematical errors:
awk (shell/*nix command) needs to be lower case (unless you aliased it)
awk accepts a short program in its first parameter, so you must make sure the script is ONE string constant (e.g. by single quoting it)
there is no input file to awk .
getline ( awk "action") needs to be lower case
Overtime is weighted twice with its weighting factor.
"equal" testing is done with == ; a single = is an assignment.
wrong algorithm for the NetPay
although pointed to by Scrutinizer, you're STILL using the � char.
your printf statement can't work: the format string is not sufficient, and the variables are not handled correctly (separate them from the format string)
And, what are you doing with the payroll variable read in the BEGIN section?