Qbasicnews.com

Full Version: Can someone please help?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
It will do the gross pay, but it doesn't seem to want to do the number of dependents and i need to round it to the nearest cen..but I am not sure were to put the INT..I have had the FLU for the past week and wasn't able to make class Thursday or Friday..could someone HELP..I only need to know what it is I am doing worng...

Thank You
Joseph L. Gelsomino




CLS
PRINT " ENTER DATA AS NEEDED:"
PRINT
PRINT
INPUT " EMPLOYEE NUMBER ===================>", EMPLOYEE.NUMBER
INPUT " NUMBER OF DEPENDENTS===============>", NUMBER.OF.DEPENDENTS
INPUT " RATE OF PAY========================>", RATE.OF.PAY
INPUT " HOURS WORK=========================>", HOURS.WORK
GROSS.PAY = HOURS.WORK * RATE.OF.PAY
FEDRAL.WHITHOLDING.TAX = .26 * (GROSS.PAY - DEPENDENTS * 40.46)
NET.PAY = GROSS.PAY - FEDERAL.WHITHOLDING.TAX
PRINT
PRINT
PRINT "GROSS PAY===========================>", GROSS.PAY
PRINT "FEDERAL WHITHOLDING TAX=============>", FEDERAL.WHITHOLDING.TAX
PRINT "NET PAY=============================>", NET.PAY
That's because you referred to "DEPENDENTS" and not "NUMBER.OF.DEPENDENTS".

replace
"GROSS.PAY - DEPENDENTS * 40.46"

with
"GROSS.PAY - NUMBER.OF.DEPENDENTS * 40.46"
1) Unstick the caps button. I swear this is the last time I'm responding to a post with caps code.

2) Check your variables....

Code:
CLS
DIM employee.number AS LONG, number.of.dependents AS LONG
DIM rate.of.pay AS DOUBLE, hours.of.work AS DOUBLE
DIM gross.pay AS DOUBLE, federal.witholding.tax AS DOUBLE, net.pay AS DOUBLE
DIM temp AS LONG
PRINT " Enter data as needed:": PRINT : PRINT
INPUT " Employee number ===================> ", employee.number
INPUT " Number of dependents ==============> ", number.of.dependents
INPUT " Rate of pay =======================> ", rate.of.pay
INPUT " Hours of work =====================> ", hours.of.work
gross.pay = INT(hours.of.work * rate.of.pay * 100) / 100
federal.witholding.tax = INT(26 * (gross.pay - number.of.dependents * 40.46)) / 100
net.pay = gross.pay - federal.witholding.tax
PRINT : PRINT : PRINT "Gross pay ==========================> ", gross.pay
PRINT "Federal witholding tax =============> ", federal.witholding.tax
PRINT "Net pay ============================> ", net.pay

Edit: Toonski, that's not the only variable name problem with his code.
Thank You for the help...now I understand what to do with the INT command...I wasn't sure if it had to be done on another line, its better that it can be done on the same line...The one thing I don't understand yet is the DIM command...we haven't had that in class yet...could you please explain...and also the Teacher wants everything in caps...sorry...I will make sure not to have the caps on if I have to post a question...

Thanks
:|

:|

:|

I guess you don't *have* to use the DIM's, but then the user could input, say, 5.1 employees and it would still be counted. The DIM sets a data type for the variable. A data type is how it is stored internally inside the program. INTEGER would have 16 bits, from -32767 to 32768. LONG would be from -1.4 billion to 1.4 billion. SINGLE and DOUBLE supports decimal stuff, but it's a lot slower than the rest.

All variables are DOUBLE by default, I believe. Unless you do "DEFINT A-Z" (guess what that does...), or similar.

To answer your first "question", you can do it on separate lines, like this, for example:

DIM temp AS INTEGER
temp = hours.of.work * rate.of.pay * 100
gross.pay = temp / 100

PS: I vaguely remember some other question of yours where you said the same thing about the caps.. sorry...
Aga: What's wrong with all-caps code? That's how it is in the IDE, and perhaps wackowolf copied it directly. Why go through the trouble of completely retyping it?
AGA: NEEDS NEW MONITOR.

Big Grin
It's not all caps in the IDE. :o
Aga: Yes it is...The QB IDE converts all code into caps.
All code, not all variables.
Pages: 1 2 3 4